Setting a Member-specific Login Redirect

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 →

Was this article helpful?

Comments

2 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

Please sign in to leave a comment.