Member-specific Pages and Login Redirects

Article author
Duncan Hamra

This feature was previously known as member-specific pages. 

login_redirect.gif

In this example, imagine you’ve created a specific page on your website for a member called Frank. We want Frank to visit this page each time he logs in.

To make this happen we need to override Frank’s login redirect.

  1. Navigate to the Members page and select Frank.
  2. Scroll down and open the dropdown called “Login Redirect”.
  3. Enter a page slug starting with “/” - in this case, we’ll use
    .../welcome/980s9s29we32223fe8v09-frank
  4. Click Save, and done! The next time Frank logs in, they’ll land on their specific page. 

Prevent Others from Accessing the Page.

The easiest way to accomplish this is to:

  1. Make the URL unguessable so other members won’t end up there by mistake. For example, /welcome/frank-n2938n239un109828n
  2. Add this code before the closing </body> tag in your CMS collection or static page. 
     <script>
    const redirectTo = "/access-denied";
    
    window.$memberstackDom.getCurrentMember().then(({ data: member }) => {
      if (member && member.loginRedirect) {
        let redirect = member.loginRedirect;
        let currentPath = window.location.pathname;
        if (currentPath !== redirect) {
       	 window.location.href = redirectTo;
        }
       } else {
         window.location.href = redirectTo;
       }
    });
    </script>
  3. Remove/modify your sitemap so search engines and savvy browsers can’t see what pages are available on your site. This is a best practice when using Memberstack anyway.
  4. Remove any public links pointing to the page.

If you do those 4 things, your site is as secure as Google Photos!

Create a Dynamic Dashboard Button →

You can use the data attributedata-ms-action="login-redirect"to create a button that will dynamically redirect the user based on their login redirect.

The button is only visible if a member is logged in.

 

Keywords: Member-specific pages, user-specific page, userspecific, memberspecific, 

Was this article helpful?

Comments

11 comments

  • Comment author
    Jack Heerink

    How do you link back to a member's specific login page if you have multiple pages under gated content? 

    0
  • Comment author
    Duncan Hamra

    Jack Heerink You'll need to link your gated content pages together or create a "hub" page that links out to all of the pages.

    0
  • Comment author
    Nicholas Platt

    Is there any way to use this Login Redirect feature for user-specific links? I want to be able to redirect a user to where I want based on custom information store in their profile. 

    1
  • Comment author
    Nicholas Platt
    • Edited

    I'm looking for some code similar to this, but I can't get it to work:  

    <script>
      memberstack.onReady.then(function(member) {
        var url = member.attributes["post-discovery-attributes-2a"];
        var els = document.querySelectorAll("[data-memberstack-attribute='post-discovery-attributes-2a']");
        for (var i = 0; i < els.length; i++) {
          els[i].href = url;
        }
      });
    </script>

    1
  • Comment author
    Duncan Hamra

    Let's see... something like this? https://docs.memberstack.com/hc/en-us/articles/10125200009627-Dynamic-Links-using-Custom-Fields

    1
  • Comment author
    KC Katalbas

    Is there a way to set member-specific sign up pages upon sign up?

    Say its set to ' /980s9s29we32223fe8v09-frank ' in login redirect on default but I want to be 
    ' /welcome/980s9s29we32223fe8v09-frank ' 

    Is there a way to automate that within memberstack?

    1
  • Comment author
    Nicholas Platt

    Hey KC Katalbas, you may just be trying to edit the login redirect section of Memberstack which is explained here: https://docs.memberstack.com/hc/en-us/articles/7384608370715-Setting-Redirects-for-Signup-Login-Logout

     

    This might be overkill but watch this tutorial which helped me figure out how to drive users to custom webpages after signup: https://www.youtube.com/watch?v=ukmzHvYfs-8&t=877s&ab_channel=SurvivingYour20%27s

    I don't follow his solution 100% because the Zapier Zaps take time to create the profile and get everything setup. Instead, I send the user a confirmation email with the signup link which gives Zapier time to process all of the steps I have setup.

    1
  • Comment author
    Duncan Hamra

    Hey KC Katalbas 👋

    It's possible to update a member's login redirect using Make or Zapier, but not automatically inside Memberstack.

    And can you show me where it says it's set to '/980s9s29we32223fe8v09-frank' by default? I'm not 100% sure what you mean. 

    The good news is you're able to enter whatever page slug and path structure you want 🎉 So starting with /welcome/ shouldn't cause any issues. 

    0
  • Comment author
    Duncan Hamra

    And thank you Nicholas Platt for sharing those solutions 🙏 

    0
  • Comment author
    KC Katalbas

    Thanks Duncan Hamra! I ended up using Zapier. I was a silly goose and had already set up a zap for it, but thought it was going through on default. Thanks Nicholas Platt as well! 

    1
  • Comment author
    William Sayer

    Thanks for the article Duncan, however...
    I have copied and pasted your code exactly but keep getting this error: 
    Uncaught TypeError: Cannot read properties of undefined (reading 'getCurrentMember')

    0

Please sign in to leave a comment.