Forum Academy Marketplace Showcase Pricing Features

After login redirect to page depending on user type

I have a usertype field in the user db which csn be either ‘customer’ or ‘business’. When users login I want to direct to different hoem page depending on their usertype. I cant seem to find an elegant way to do this. Obviously you cant put conditional on the button since the user hasnt logged in yet, and a workflow cant have 2 conditional naviagte to page. Even tried using custom event but this doesnt work either. Any ideas?

Right after logging in, redirect to both pages in the same workflow, but put conditionals on them based on the user type.

Workflow actions now have conditions on them. So you can make an action to go to a certain page “only when” the user’s type is X and another action to go to a different page “only when” the user’s type is Y.

1 Like

If you want to see an example of redirecting a user based on a user type using a workflow condition, you can use my Free Landing Page template and check out the workflow used for Login and Signup buttons
https://thefreelandingpage.bubbleapps.io/3
(go to the link above, click ‘Get Now’ on the right, on new page scroll down and add the app to your templates, then go to main Bubble page/dashboard and go to create a new app, and select this template from the template dropdowns to access it in editor mode!)

As Eric said, you currently can’t have two navigation actions following each other under the same event. However, you can create a custom state with different values, which become set after the User logs in, which then redirect the User to the correct page.

The custom state could be set on the Login Button called “Page Redirect” (Type: Text, List: No). Then you can create two “Do When Condition is True [every time]” events which will redirect the User.

For example, with two UserTypes (Customer and Business), the workflows could be:

“When Login is clicked” -->
Action 1: Log the User in
Action 2: Set state of Login Button, Custom State: Page Redirect, Value = Customer (Only when Current User UserType is “Customer”)
Action 3: Set state of Login Button, Custom State: Page Redirect, Value = Business (Only when Current User UserType is “Business”)

Then two ‘Do When Condition is True’ Events -->

  1. “Do When Condition is True [every time] and Login’s custom state is ‘Customer’”
    Go to page --> customer_home
  2. “Do When Condition is True [every time] and Login’s custom state is ‘Business’”
    Go to page --> business_home
2 Likes

I just tested out what I had suggested earlier (subsequent “Go to page…” actions with conditions) and it solves the initial problem, unless I’m missing something from the original post.

It brings up an error stating the page redirect must be the last action in the workflow:

Thanks for pointing out that it flags an issue. I reviewed the issue checker and I had the same issue buried in there. I feel that when there are conditions on page redirects, an exception should be made. This would make for an easy solution, but it won’t be deployed with that error present as it currently stands.

2 Likes

No problem, :slight_smile: I didn’t notice it at first as well. I agree with you, perhaps an exception could be made; it would definitely make redirects much easier to setup and manage.

1 Like

I got around it by adding custom event that directs 1 user type and if that isnt the user then the traditional page navigation is used (both with condition tests)

4 Likes

Could you do it in the UI before it gets to workflows, like if the user is type:business only show them the “business” button and hide the “not business” button?

What Eric was trying to do was use a single button that redirects to the right page without knowing beforehand the type of user. Your case seems to be a little different. If the user is logged in already, you can show or hide a button with conditions on the button, passing the user type. If the user isn’t logged in yet, make sure the page with the button was navigated to by the appropriate user type (i.e. only business users would normally only reach this page while other users would reach another page).

Although it would be be possible to have two buttons with conditions that show/hide depending on the User “Type” without needing that user to be logged in. Although I think you would need to be defensive and have a condition on the page load of each type that does a redirect.

However … all a bit complex for something that now sounds like it should not be an issue.

This topic was automatically closed after 70 days. New replies are no longer allowed.