Conditional Page Redirects

Sharing this here in case anyone in the future encounters the issue and needs a solution:

If a user arrived at Page 1 and had Attribute A, I wanted to redirect them to Page 2, instead. I put a conditional node on Page 1’s logic using an IS_EQUAL formula.

But it didn’t work.

I eventually got it to work by putting the conditional redirect at the very end of the previous page’s logic flow so that it directed them to either Page 1 or Page 2, rather than waiting until they had arrived at Page 1 to make the decision.

1 Like

This is the correct architecture anyway – you wouldn’t want to have Page 1 in-between your original page and Page 2, as then going back would bring you to Page 1 instead of the root page.

Hi Erin.
Thanks for the tip.

In my case I would like a redirect to users that try to visit a page without credentials.
Like if for some reason they land on a lets say an admin page, I would like to redirect them and not mount the page for them to view.

How would you tackle that?

@Silenux,

In our app, we handled that by making the buttons leading to the page visible IF the user had the right app variable.

For example, the visibility for the button to go to the admin page is a formula: appVars.currentUser.status==“admin”. It returned TRUE (visible) if they’re an admin, and FALSE (invisible) if not.

Or if I want to send them to Page 1 or Page 2 based on their status, I put an IF condition on the page where they’re clicking the button–not the page they’re landing on.

Yes I’m using something like that with user groups. I created an admin group and other users and if the current user is not in the admin group I don’t render links to the admin area.

I solved my main issue with this.
I did an extra check if for some reason somebody unauthorized lands on the admin area, on page mount I check the admin group and send the user to another page if it doesn’t pass. I do that check while there’s a loading indicator and don’t show content until it passes.

Be sure to test that thoroughly. When I tried to do that, it created some odd behaviors. (Although it’s entirely possible that I was doing it incorrectly.)