How to restrict access to login and signup pages for logged-in members? Answered
Hi, is it possible to only allow access to certain pages for members that are not logged in? I would like /login and /signup to not be accessible when someone is logged in
Comments
6 comments
you can do it with a bit of custom code
Awesome! You're right, William de Broucker 👏
To further tailor it down to your request Cameron Bensimon, I added the condition for the /login and /signup.
<script> window.$memberstackDom.getCurrentMember().then(({ data: member }) => { if (member) { if (location.pathname === '/login' || location.pathname === '/signup' ) { window.location.replace('/'); // replace the current URL with the root URL } } }) </script>Thanks guys! William de Broucker Chukwudi
Hi everyone,
I know this thread is old but I need some new help with it!
I am using this because of the following:
When someone pays for my plan, while they are logged in the signup page is prepopulated with their information, but it does not prevent them from checking out. The result is that there are no required fields and unlimited access to the Stripe checkout page to keep paying us without receiving anything.
So, this is allowing me to prevent logged in people from accessing a dysfunctional checkout page.
There is still one problem: if someone abandons their cart, they are now logged in. This means they cannot access the cart without logging out. When they do log out, they will not be able to use their logged in email address. I want abandoned carts to be able to purcase at a later time!
Can code be added to this so that only people logged in who have access to my paid plan are barred from the signup page?
is there someone to help? I want to make logged in members to access only certain URL's and if they are not logged in, to not let them access those URL's. How do I do this?
Hi Karolis,
You can achieve that using our gated content feature.
Alternatively, you can add the Javascript code below before the </head> section of the restricted pages.
Please sign in to leave a comment.