Skip to main content

Redirect to conditional page after login

I have 2 types of users and i want to redirect users according to his role type,how i can redirect him conditionally after login

Official response from

Hi Neeraj-

You can accomplish this by using a liquid conditional statement with javascript (for the redirects) inside of it. For example, you could include this in the landing page:



{% if request.current_signup.tags contains 'role1' %}

<script>

window.location.href = 'http://www.yourdomain.com/user1';

</script>

{% elsif  request.current_signup.tags contains 'role2'%}

<script>

window.location.href = 'http://www.yourdomain.com/user2';

</script>

{% else %}

<script>

window.location.href = 'http://www.yourdomain.com/neitheruser';

</script> 

{% endif %}

 

 

It is also worth noting that you can use the same type of liquid conditional statements to configure a single page to look differently depending on what tags a user has. So rather than using redirects, you could just make your homepage display completely different content depending on which role the logged-in user has been tagged with.

Share this post

Showing 3 reactions

How would you tag this suggestion?
Please check your e-mail for a link to activate your account.