How to redirect based on Role (M2M Collection relationship)

I’m struggling with trying to get users to a different “homepage” based on their role.

Adalo doesn’t seem to like it if their role is assigned by way of a collection relationship.

For example I have a collection of Users and a collection of Roles.

A user can hold multiple roles, and each Role contains multiple users, clearly.

However, when I try to set up the Login button to link to a different screen based on their Roles, it doesn’t work. Is this because it is a list?

When I try to set the button to Login, then another action of Link → User Page (sometimes) Logged In User’s > Roles > Contains it doesn’t give me any options to choose from, but only allows me to type in the box. However, if I just type in the name of one of the Roles, such as “Driver” it doesn’t work at all.

If I have that as the only link option, it doesn’t link anywhere and just sits on the login page.

How do I get the Link to be able to detect which Roles the user has without using another field in the Collection like a text value as that entirely defeats the purpose of having various roles set for various users.

Since this is the login page I can’t show a different login button via Visibility settings with different Links based on who is logged in, because they aren’t logged in yet!

Thanks!

The easy way here is to make the button a list!

This will list all of the roles the user has, when they click it and go to the home screen, it’ll pass the role information to the screen.

If you want to only show one role and pass that info to the home screen, then make the button a list and filter the list to show that specific role.

I use this way too many times in my apps when you want to pass dynamic information to screens but don’t have a list to start with.

I could see how this would work in other situations, but it doesn’t work for a Login button because the user is not logged in yet.

I can’t display a list of roles for a user who isn’t logged in.

Are you making a delivery/uber eats style app? If so, there’s a better way to do this.

If not, you can make a custom sign in form and use the button list solution I posted above.

No, it’s not an Uber style app, it’s an in-house company app.

I don’t want to pass the role information anywhere. I want the Login button to go to a different page depending on what the Role of the user trying to Log In is.

I don’t want the user to login, go to a screen, then be redirected to a different screen based on their role. I want the button itself to link them there directly.

Basically the company has drivers, admins, dispatch and managers

I want them to go to different places depending on those roles.

I really appreciate your help but maybe I’m not explaining clearly enough what it is I’m trying to do.

Or Adalo just isn’t capable of doing it.

I guess I do want to capture their role information, however I thought that was just inherently available information once they are logged in. But that doesn’t seem to be the case?

Even after the login, I can’t set a generic “redirection” with Page Actions depending on what their roles are, either. It doesn’t work.

Hi, this is definitely possible. It would be useful to know about the specific use cases.

Below I’ve posted an image of using a loading screen to direct users. You can sort them using binary actions on those screens.

If you have multiple roles, you need to provide Adalo with the knowledge of where you want the user to go. For delivery, where we have drivers and businesses, we normally put conditional visibility buttons at the top of the screen that allow them to go to specific pages.

Basically the setup is like this. I have various users in the collection, right, with an linked Roles collection.

Driver’s basically only have 1 role, Driver, but other people like the owner of the has multiple roles. Admin, Manager, Driver, Dispatch, as he will fill all of them from time to time.

I think I am misunderstanding how the relationships work and how you can access the data. Apparently Adalo isn’t able to see, for example, that a Logged In user’s Roles are Admin, Manager, Driver when trying to set an action. You have to tell Adalo WHICH ONE of those Roles you want that User to be currently associated with…I think.

Even if I do this:

  • User logs in with email and password (login button ONLY logs them in)
  • Have a button list below displaying Logged In User’s Roles
  • User clicks the Role’s button and goes to the next page

When I try to set a Screen Action, I am unable to tell Adalo to do something based on the Logged In User’s “Role” which should have been sent to the page by the previous button press. It’s simply just not an option.

The only way I have been able to do this is to have the button set a field in the User, say like “setRole” to whatever role they click, then redirect them based on that field.

Ideally I DO NOT WANT to “redirect” the user anywhere. I want them click ONE button. “Login” and it will detect if their Roles includes certain things like Driver or Admin and send them to the appropriate screen. It doesn’t appear like I can do that within a single “Screen” though.


Basically I just want Adalo to be able to do this:

“If the Logged In User’s list of Roles contains “whatever Role” → Do something”

But I Adalo can’t do that apparently.

Okay, I better understand what you’re trying to achieve now. I think what you’re missing is that you have to explain to Adalo what you want it to do. Adalo can’t guess in M2M.

I’d add binary options to roles, I wouldn’t have a relationship.

Below I’ve posted a picture of how I’ve set up this relationship in the past. Once you have the binary options Driver vs Admin, you can send admins to the admin screen and drivers to the driver screen.

If you want admins to be able to see every screen, give them that nav in the admin console. I’ve also put conditional visibility buttons on the home page, so business owners can leave the home page to go to the business page and same for drivers.

You can give admin the ability to go to any page (via their own menu).

Right, I understand.

I was just hoping I would be able to get around using true/false settings.

Reason being is I want to display the roles a user has in the user list, which uses a list of Roles. I didn’t want to use multiple fields to accomplish this, for example, a relationship to the Roles collection in order to display the list of roles assigned to the user, AND have a toggle switch for the associated roles.

But I guess there’s no way around it.

You could have M2One. Send drivers to the driver screen, admins to the admin screen. Give admins the ability to go to any screen via their menu.

You just need some way other than M2M for Adalo to know where you want the user to go.

I just made Admin, Driver, etc true/false fields instead.

Since you are only able to choose 1 screen for all users to be sent to when they are logged in I basically have no choice but to set up a redirect page and send the users elsewhere depending on admin//driver true-false fields. Oh well.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.