Hide content from logged-in members

Article author
Josh Lopez
  • Updated

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

How to hide an entire page from users with an active membership.

Hide an entire page from active members

Add this code to the header (between <head></head> tags in your website code) of a page to redirect users who DO have an active account/membership. Replace the "/member-page" with your desired destination page. This code could be helpful if you want to prevent members from accessing a page that's only useful for new visitors.

<script>
  MemberStack.onReady.then(function(member) {
    if (member.loggedIn === true) {
      window.location.replace("/member-page")
    }
  })
</script>


Don't need to hide an entire page? Hide part of a page from members.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.