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 below the Memberstack script and replace "YOUR_FULL_URL_HERE" with your full url like "https://memberstack.com".

<script>
  MemberStack.onReady.then(function(member) {
    if (member.loggedIn) {
    window.location.replace("YOUR_FULL_URL_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.