Redirect after Signup back to page they came from - with Delay

Hi! I am using the powerup given by memberstack called Redirect after Signup or Login: https://app.memberstack.io/power-ups

The issue is as follows:

When someone browses my website they reach a section that has members-only content. When they click on this content it asks them to signup for access. When they do they are redirected back to the page they came from exactly as planned in the PowerUp.

One of the membership benefits is that they can save the content they visited. This is an operation I set up with Zapier, airtable, and memberstack. To be able to save to their dashboard the zap must have gone through and it must be ready, otherwise the saved element won`t save in their dashboard.

However, it takes a few seconds for the member’s dashboard to be ready, and some might try to save before it is ready. The save button triggers the modal telling them so sign up, so I can assume that they will click it immediately after creating their membership.

So I want there to be a delay from when they signup until they are redirected back to the exact same page they came from, and that the page is refreshed.

I assume it is not that difficult, as I only need the hidden page to load a few seconds before redirecting, but not sure how to set that up correctly.

Thanks

Paul

So this screencast walks you through how to redirect, with delay, once the membership is all setup:

The difference being that you need it redirected to a page other than their member page?

If so, you just need to save the destination URL (in a cookie for example) and instead modify the script in that screencast to redirect to your saved destination URL instead of the members page.

2 Likes

Hi @ChrisDrit! Thank you for your reply. I did already follow that video. I am not super good with scripts, but I assume that this part from the Memberstack PowerUp sets a Cookie called ‘redirect’

<script>
  MemberStack.onReady.then(function(member) {
  if (!member.loggedIn) sessionStorage.setItem('redirect',window.location.href);
  })
</script>

Then in the script in your screencast, I have to modify it so it redirects to the ‘redirect’

And it is here I am lost, as I am not able to write that script. I assume it is just details and logic, but not sure.

Here is the script that I need to edit:

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

If anyone knows how to edit the script so it works for the purpose I want, then it would make my day!

Thanks

Paul

1 Like

So I’m not familiar with that, but if the code snippet you’ve provided is something that does indeed work:

sessionStorage.setItem('redirect',window.location.href);

Then all you would have to do is replace this from my snippet:

window.location.replace(member.memberPage);

With something like this:

let myRedirect = sessionStorage.getItem('redirect');
window.location.replace(myRedirect);

Again, I haven’t tested ANY of that, so I’m just providing some guidance here, but that sounds reasonable to me.

You can see what’s available with sessionStorage here: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage

Thank you @ChrisDrit! It worked perfectly.

Now I just need to configure a hidden loading page as the landing page after they sign up, and it should be all good!

I love this community!

Thanks again!

Paul

2 Likes