-
- 288 Posts
Hello, I'm trying to find a way of making the Login snippet redirect the user after login, but not to the previous page they were on, instead to a page URL (for a restricted access page) that they clicked on in the nav menu.
For example, in a dropdown in the front end site I have a menu link to a certain page, let's say restricted.html. The user clicks on the link and gets redirected to the Login form page to validate themselves. Then after logging in (and this is the bit I can't work out) they need to be redirected to restricted.html (which they can now access).
As far as I can see, the redirectToPrior setting won't work in this case because the user didn't come from the restricted.html page. Is there something else that can be used?
Thanks!
-
- 932 Posts
Where '18' is would be the id to your restricted.html
-
- 24,544 Posts
Is the page you're sending them to in another context? That requires the &contexts property in the login snippet tag.
If you put a link to the protected page on the Login page and remove the redirect so the user stays on the Login page after logging in, does the link work? If not, your permissions may not be set up correctly.
-
- 701 Posts
&redirectToPrior=`1` should work.
When the user clicks the restricted page is the url the correct one for that page but showing the unauthorizes page. Or is it showing the url to the login page?
-
- 288 Posts
I've set the Unauthorized page to be the Login page. So this is how the scenario should go:
User clicks on link for restricted.html in the dropdown menu. It's a restricted page so they get sent to login.html instead.
When they log in, they should be sent to restricted.html automatically.
But redirectToPrior won't work with this (I've tried) because it sends users back to the page they were on before they logged in (which could be any public page on the site, because they could have clicked the link on the menu from any of those pages). What I need is for the Login snippet to somehow know that they tried to access restricted.html, store that somewhere during login and then redirect to THAT page after they log in...
-
- 932 Posts
have you tried the isloggedin snippet?
' Will check to see if user is logged into the current or specific context. If not, redirects to unauthorized page.
'