Hey Julian Galluzzo So thatās the problem, is they would be redirected to a login page that is a step after. I have a custom JS script that inserts a cookie and then redirects back, but thought there might be a cleaner way š
this way would probably work better than with a cookie since cookies usually take more time to get recognized after the page load (from what ive seen) - the one in this example is pretty much instant, you dont notice you're even being redirected to the "in between" page unlezs you stare into the url bar and catch the few ms of loading time
Sweet! I have to ask, what's the need to clear the location? I would think it would just be a harmless URL saved in the local storage.
Regardless, I have an idea - a script somewhere in the body which checks if _ms-mem is saved in their local storage (only true if user is currently logged in)
If it is present, clear location from local storage
if someone logs in on the profile page I want them redirected back to the profile page, if they login from the homepage, I want to redirect them to the redirect page set for their plan
in short if they login at /profiles/ redirect to the page they were on
If any other page, redirect to the redirect link as per the memberstack plan
Maybe a question for Jayess. Iām looking to achieve this login/register redirect too and I see in the Docs under ādata-ms-form=āloginā that it says "Adding a redirect to the form element will override redirects saved in Memberstack." Sounds perfect, but there isnāt an example of this āredirectā method in the HTML snippet. Is this a feature of Memberstack or something that hasnāt made it to Prod yet?
Iāll use the localStorage method in the meantime.
Marc Hudson if you're using Webflow, you should just be able to add the form redirect URL in the settings - that being said, that would only work if you have a bunch of different signup/login pages - this method allows you to use one page and have it redirect accordingly
Hey Julian Galluzzo. Ah, I forgot about that. I tested that option but unfortunately it seems Memberstackās Redirect on login (User specific) value is trumping the forms redirect value. I was hoping individual forms would have the final say but it doesnāt seem thatās the case. Iāll use the localStorage method š
I should say that I have 2 different login forms. 1 generic login that redirects each user to their Dashboard and another that appears on specific pages that Iād like to redirect to. Thatās why the formās redirect value having the final say would be handy in this case
Comments
15 comments
Hi Connor š
Great question! Hm, try this out and see if this fits your use case š
Thatās useful Jayess
Does this also work for example if we ask someone to login from an article page? User flow would look like this:
Article page > Login page > redirect back to the article page after success?
Chuck Lapointe yup! Whatever page they logged in from will work.
Heres a demo we just released which should help along with the article shared by JS
https://webflow.com/made-in-webflow/website/dont-redirect-on-login-memberstack
Hey Julian Galluzzo So thatās the problem, is they would be redirected to a login page that is a step after. I have a custom JS script that inserts a cookie and then redirects back, but thought there might be a cleaner way š
this way would probably work better than with a cookie since cookies usually take more time to get recognized after the page load (from what ive seen) - the one in this example is pretty much instant, you dont notice you're even being redirected to the "in between" page unlezs you stare into the url bar and catch the few ms of loading time
sounds good! Thanks
No problem!
so, in this example would always be redirected back to the page that they were on. I only needs to work on a few select pages, but on every page
@Connor Finlayson Idea:
https://www.loom.com/share/b2e5c66707624bbbb981f53d741107b5
hey this actually works nicely. I just need to find a way to clear the location once they have been redirected back to that page
Sweet! I have to ask, what's the need to clear the location? I would think it would just be a harmless URL saved in the local storage.
Regardless, I have an idea - a script somewhere in the body which checks if _ms-mem is saved in their local storage (only true if user is currently logged in)
If it is present, clear location from local storage
if someone logs in on the profile page I want them redirected back to the profile page, if they login from the homepage, I want to redirect them to the redirect page set for their plan
in short if they login at /profiles/ redirect to the page they were on
If any other page, redirect to the redirect link as per the memberstack plan
Maybe a question for Jayess. Iām looking to achieve this login/register redirect too and I see in the Docs under ādata-ms-form=āloginā that it says "Adding a redirect to the form element will override redirects saved in Memberstack." Sounds perfect, but there isnāt an example of this āredirectā method in the HTML snippet. Is this a feature of Memberstack or something that hasnāt made it to Prod yet?
Iāll use the localStorage method in the meantime.
Marc Hudson if you're using Webflow, you should just be able to add the form redirect URL in the settings - that being said, that would only work if you have a bunch of different signup/login pages - this method allows you to use one page and have it redirect accordingly
Hey Julian Galluzzo. Ah, I forgot about that. I tested that option but unfortunately it seems Memberstackās Redirect on login (User specific) value is trumping the forms redirect value. I was hoping individual forms would have the final say but it doesnāt seem thatās the case. Iāll use the localStorage method š
I should say that I have 2 different login forms. 1 generic login that redirects each user to their Dashboard and another that appears on specific pages that Iād like to redirect to. Thatās why the formās redirect value having the final say would be handy in this case
Please sign in to leave a comment.