How to set up conditional login redirects in a multi-dashboard system based on user role and form location? Answered
Hey guys, just wondering if there is a way to change the login redirect based on where they are logging in?
Use case - We have two dashboards built into our system, a regular user logs in via login form 1 and sees the first dashboard, the higher user logs in to the secondary dashboard via login form 2, but they also have access to the first dashboard so we want them to be able to redirect to that if they’re logging in via login form 1.
Comments
2 comments
Here’s some Javascript/jQuery I use to redirect forms to any page after submit. It’s a common approach but I’ve added some functions to check it’s an XXS safe querystring value, that it’s a relative URI and a form submit listener. Let me know if it doesn’t work because I’ve simplified it a bit.
If you add a ?destination=foo querystring on the login page, it should redirect on form submit/page reload.
Thanks for that code + explanation Marc Hudson! 🙏
Jamie Debnam, you can also set the redirect directly on the login form. It will completely override any plan level or default login redirects, so be careful if you decide to go that route.
Please sign in to leave a comment.