How can I create a list that shows different results depending of user type?

Hi, I am creating an app that has a page on which the list of registered users should be displayed. The problem is that there are three types of users (in this case students, parents and teachers) and they need to be able to display the list with only other people with the same role (e.g. students need to display the list of only students, teachers the list of only teachers etc.).

Until now I have used 3 different lists because I could not find another way but I am asking you to find out if it would be possible to create this functionality with just one list.

Thank you for your attention,
Have a nice day:)
Pietro

Hi @pietrogiuseppe

You need to filter the list dynamically according the the role field in your user table, eg. role = logged in user role

Search the help docs and forum to learn about logged in user v current user.

Thank you, the users in my app are defined with a true/false property.

Can you please explain in detail what you mean?

Thank you very much for your support,
Pietro

I would change it to a text string, it is easier to filter 1 text field versus filtering three boolean fields.

Hi @Rozza,

Thanks for your help! I’m not too familiar with the technical terms you mentioned. Could you give me more details and explain your instructions in simpler terms? Also, could you let me know the specific steps you’d take on Adalo?

Appreciate your patience.

Best,
Pietro

Create a new collecion “Role” to your database


Define the roles.

Add the relationship “Role” to your users-collection as R - UUUU (a Role can have multiple Users, a User belongs to one Role)


Create your users.




Add a list to your screen
Filter your list



1 Like

I’m truly grateful for your help. I’ll integrate this into my app as soon as I can.

Many thanks,

Best regards,
Pietro

Other than a dropdown to choose from, there isn’t much advantage to having a separate table. What I suggested was a text field, and then you have your permission or role in that text field, directly in the user table.

If user define their role (at the registration) in a text field it could be possible, that a pupil writes
pupli or pulpi, or …
or a parent writes Parent or paretn or…
or a teacher writes the word “teacher” wrong (YESSSS, that could be!)

That can’t be in a dropdown.

You are assuming that a user chooses their own role. There is more than one way to skin this cat.
Just because it is a text field, it does not mean it is open for only type input.

I added it in a dropdown at the sign up and is works perfect