Return to Page after Sign Up or Login

Article author
Duncan from Memberstack

This article will show you how to return members to the page they were viewing before being asked to sign up or login. This is especially handy if you have a content or functionality that is partially gated (like a blog or comment sections).

data-ms-redirect="current-url"

Use the attribute data-ms-redirect="current-url" to save the current URL. The next time that visitor goes to sign up or login they will be returned to the page. 

return to page (1).jpg

You can place the attribute anywhere, but we recommend placing it on your signup and login links. 

Considerations

Keywords:

Stay on page, stay-on page, override redirect, after login, after signup, save page, save url, current url, 

Was this article helpful?

Comments

9 comments

  • Comment author
    Mark Burlinson

    This did not work for us. 

    0
  • Comment author
    Duncan from Memberstack

    Mark Burlinson Do you have a redirect hard-coded into your signup/login form by chance? 

    I just did some testing and this feature is working as expected for me. It you can share a video or read-only link that would be super helpful to debug 🙏

    0
  • Comment author
    Joseph Carroll
    • Edited

    Duncan Hamra Does this data-ms-redirect attribute work for URL's where there's gated content?

    For context:

    - User clicks on link from email to go specific page

    - Page happens to be gated content (user is not logged in)

    - MS kicks user to log-in page (normal behavior)

    - On log in event --> page redirects from plan level redirects back to original URL they were 'kicked out of'.

    Thanks a mill!

    Joe

    ++ update ++


    I did add this attribute to the main nav of my web app. (This is a common element across my Member area.)
    This did not work. I understand it should likely be a form element.

    I did try it on my login button on my login *page* (not modal), but obviously that just grabbed the current URL (which was "log-in") which directed me back to itself.

    I have 8+ pages on my web app, sometimes I need to send users straight a specific page (once they log in). I might just hard code this as a cookie and do some logic here if this isn't native to MS. Thanks!

    0
  • Comment author
    Duncan from Memberstack

    There's no way for it to remember the first page if that page is gated. This attribute only "remembers" the current URL if it is clicked by the member. 

    Thank you for the update! I just tested the attribute on my own site, and it all appears to be working correctly. If the member clicks a link or section with the attribute they will be returned to the page on login. 

    1
  • Comment author
    Joseph Carroll

    Thanks Duncan from Memberstack! I appreciate the response.

    1
  • Comment author
    Drew Birnie

    Could I use this in the following situation:

    1. A user is taken to a pricing page where they select a recurring payment plan

    2. Upon submitting the pricing form, they're are taken to a signup form where they can either create an account or log in

    3. If the user already has an account (for a different product), they can log in and be taken straight to the Stripe payment form. 

     

    I'm scratching my head on this one as it seems like it should be pretty straightforward, but this solution seems like it would just keep them on the signup/login form. 

    0
  • Comment author
    Duncan from Memberstack

    Drew Birnie Thanks for asking!

    1. Yes, no problem. They can select a pricing plan by clicking on a button with a price attributes. 
    2. Also fine. If you add a sign up link (i.e. /signup) to your pricing button it will redirect them to your sign up page. From here they can signup or create an account. After signup they will be taken straight to checkout. 
    3. If the users already has an account and is logged in, they will be taken directly to the checkout from the pricing page. 

    Does that make more sense? No worries if not, just let me know and I'll record a video. 

    0
  • Comment author
    Drew Birnie

    Duncan from Memberstack


    What if the user has an account and is NOT logged in? I'm having issues with that scenario. This is what happens in that case right now:


    1. They select a pricing plan on a pricing page and click on "checkout"

    2. From there, they are directed to the signup form

    3. They click on "Already have an account? Log in." and are taken to the login form where they can successfully log in

    4. Once they do, they're taken to their member dashboard <<< This is where the problem is. I need them to be taken to the Stripe payment form for whichever recurring plan they selected. 

    0
  • Comment author
    Duncan from Memberstack

    Ahh right! Thank you for clarifying. 

    Have you seen this MemberScript yet? If you add it to your site I believe it will fix your issue. https://docs.memberstack.com/hc/en-us/community/posts/18410652090139-How-to-Launch-Checkout-after-Login

    0

Please sign in to leave a comment.