Redirect Logged-in Members

Article author
Josh Lopez
  • Updated

Using Memberstack 2.0? There is an updated version of this article here.

Here's a simple way to redirect a user away from a certain page and towards another page if they are logged in.

This article is a simple way to redirect a user away from a certain page and towards another page if they are logged in.

For example: some websites want to disable their homepage or pricing pages if users are already logged in.

 

Copy and paste the following code snippet into the page header.

<script>
  MemberStack.onReady.then(function(member) {
    if (member.loggedIn) {
      window.location.replace(“/redirect-me-here”)
    }
  })
</script>

This code snippet will only execute for members who ARE logged in. Keep in mind that it will affect ALL logged-in members.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.