Hey guys,
What is the solution to have a user redirected to My Account /me page after signup and login ?
There seems to be no settings for this so perhaps it needs a custom development ?
Has anyone done it before on v13 ?
Thank you in advance.
Hey guys,
What is the solution to have a user redirected to My Account /me page after signup and login ?
There seems to be no settings for this so perhaps it needs a custom development ?
Has anyone done it before on v13 ?
Thank you in advance.
You can use session hooks, on hooks.py
Take a look here:
https://frappeframework.com/docs/v13/user/en/python-api/hooks#session-hooks
Hope this helps.
Thank you for your assistance.
Unfortunately I do not have programming experience and am relying on the kindness of this forum to achieve a few things …
Hope it’s not too much to ask.
try to visit login page with redirect-to query param. e.g.
https://erp.example.com/login?redirect-to=/me
Sure but I would like to implement this solution for all the website visitors
Hi:
I’ve tested this, and it’s working on v14. After login, system will route navigation to the user form, opening his own record.
You need to edit hooks.py file . It is located under your app folder (yourbench/apps/yourapp/hooks.py). Add a line like this:
app_include_js = "/assets/app_name/js/yourapp.js"
Create a yourapp.js file in yourapp/public/js folder.
In this file, write this
$(document).on("startup", function () {
frappe.set_route("Form","User",frappe.session.user);
});
Please, note that
yourbench is the name of your bench folder on your server
yourapp should be a custom app to preserve your customization in future updates.
Maybe there is an easier method for achieve your requirement…
Hope this helps.
You can do it in Website Script
like this
$(function () {
if (location.pathname == "/login" && ! location.search && ! localStorage.getItem("session_last_route")){
const url = new URL(window.location);
url.searchParams.set('redirect-to', '/me');
window.history.pushState({}, '', url);
}
});
ex:
In case of this script also check if redirect-to already exists, only set it if it doesn’t exist.
actually
! location.search
will test for all query strings so if there is anything after ? in the url it won’t perform this appending.
You guys are amazing and I thank you sincerely for you assistance and proactive results !
Cheers to everyone
This solution is working properly, but can we give this on the basis of a specific role? When ‘Sales Manager’ login that time it should be redirected to the lead list view.
Thanks in advance
You can use default-homepage hooks, on hooks.py
https://frappeframework.com/docs/v13/user/en/python-api/hooks#default-homepage
However, system users are always redirected to /app
so you can use the solution
to redirect them to /index
If not in Website Script doctype, if directly in code where to put this code? Thanks
It is working fine in website script.
Yes I know.
But what if I want to use the script in code file (maybe to hide it from user? )
Ok sir thanks .