Log In / Sign Up and Log Out redirects

Post author
Nicklas Glad

Hi there, so I have three CMS collections where I use the Memberstack save/unsave items, and it works like a charm! Thank you Memberstack! :D

Now I'm trying to make the Log In / Sign Up and Log Out go to the current url the user is on, but I can't seem to figure out where exactly to place the attribute data-ms-redirect="current-url".

I have a two different heart icons on the CMS items, one is visible when a member is logged in and the other is visible when the user is not logged in. So the one where the user is NOT logged in I currently have a pop-up that says you need to create a profile to use the function with a "Login with Facebook", "Login with Google" or "Login with email" in a Form.

 

Where do I place the attribute?!?!?

 

Best N

Comments

1 comment

  • Comment author
    Josh Lopez

    Hey there!

    It sounds like you’re on the right track with your Memberstack integration! To address your question about where to place the data-ms-redirect="current-url" attribute, here are some tips that should help:

    Where to Place the data-ms-redirect="current-url" Attribute:

    You want to apply this attribute directly to your login, signup, and logout buttons or links. This ensures that users are redirected back to the same page they were on after logging in or signing up.

    Example:

    <a href="#" data-ms-action="login" data-ms-redirect="current-url">Log In</a>
    <a href="#" data-ms-action="signup" data-ms-redirect="current-url">Sign Up</a>
    <a href="#" data-ms-action="logout" data-ms-redirect="current-url">Log Out</a>
    

    These buttons should be visible to users who aren’t logged in (for login and signup), and hidden from logged-in users, which you can achieve using Memberstack’s visibility attributes.

    Additional Points:

    1. Testing: After implementing the attribute, make sure to test the behavior by logging in and out on different pages to confirm that the redirect works as expected.

    2. Onboarding Considerations: This attribute won’t work with the onboarding UI of Memberstack. If you’re using an onboarding process, ensure that this redirect behavior doesn’t conflict with any onboarding redirects you may have set up [source, source].

    3. Visibility for Logged Out Users: Since you mentioned using heart icons for logged-in and logged-out states, you can leverage Memberstack’s visibility attributes (data-ms-content) to ensure that only the appropriate buttons are shown based on the user’s logged-in status. For example:

      <a href="#" data-ms-content="!members" data-ms-action="signup" data-ms-redirect="current-url">Sign Up</a>
      

    I hope this helps! Let us know if you have any further questions or need additional guidance! 😊

    0

Please sign in to leave a comment.