[solution] Javascript snippet to redirect to page prior to sign up

Hi,

I’ve hacked the JS so that it waits on a page with a ‘loading spinner’ whilst the user’s account is set up, before then redirects the user to the page they were originally on before sign up.

It works, but is sometimes very slow and the user is kept on the holding page for a long time! I guess the depends on the load on Zapier/memberstack/webflow.

<!--Place this on your page after signup/login - must be a hidden page-->

 <script>
 var Webflow = Webflow || [];
 Webflow.push(function() {
MemberStack.onReady.then(function(member) {
if(member.memberPage){
//window.location.replace(member.memberPage);
var redirect = sessionStorage.getItem('redirect')
  sessionStorage.clear();
    if (redirect) window.location.replace(redirect)
  } else{
    setTimeout(function() { location.reload(true); }, 3000);
    }
  }) 
});
</script>

I hope this helps someone.

Also, if anyone has any suggestions to optimise or improve the JS, please feel free to make suggestions.

JT

3 Likes

Thanks, JT! Really appreciate you sharing this :grin: