Redirect a member to the login page Answered

is where anyway to redirect a member back to the page they logged in from?

Comments

15 comments

  • Comment author
    Jayess

    Hi Connor šŸ‘‹
    Great question! Hm, try this out and see if this fits your use case šŸ˜€

    0
  • Comment author
    Chuck Lapointe

    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?

    0
  • Comment author
    Julian Galluzzo

    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

    0
  • Comment author
    Chuck Lapointe

    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 šŸ˜…

    0
  • Comment author
    Julian Galluzzo

    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

    0
  • Comment author
    Chuck Lapointe

    sounds good! Thanks

    0
  • Comment author
    Julian Galluzzo

    No problem!

    0
  • Comment author
    Connor Finlayson

    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

    0
  • Comment author
    Julian Galluzzo

    @Connor Finlayson Idea:
    https://www.loom.com/share/b2e5c66707624bbbb981f53d741107b5

    0
  • Comment author
    Connor Finlayson

    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

    0
  • Comment author
    Julian Galluzzo

    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

    0
  • Comment author
    Connor Finlayson

    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

    0
  • Comment author
    Marc Hudson

    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.

    0
  • Comment author
    Julian Galluzzo

    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

    0
  • Comment author
    Marc Hudson

    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

    0

Please sign in to leave a comment.