Hello Bubble community,
I’m working on a feature where I need to implement conditional logic for a search box based on the user’s role. Specifically, I want to make sure that the search results are filtered so that teachers can only see students associated with them and not students associated with other teachers. However, since the reusable that contains the search box is also used on the admin dashboard, I still want to allow admins to see all students using the same search box. Is there a way to achieve this? Like a condition that would change the list of users it searches for based on user role?
Here’s the context of my question:
- The search box is currently set up for teachers only. This prevents students who are associated with other teachers from showing up in the search results. This search box is only visible if the user is a teacher.
- I’ve duplicated the search box as a workaround to allow admins to search all users. This search box is only visible if the user is an admin.
- We cannot use privacy rules because we need teachers other than the student’s current teachers to be able to see the student’s information (e.g. previous comments made by other teachers) as long as those teachers belong to the same educational organization.
- On the User data type, there’s a
role
field, which is an option set, and ateachers
field, which is a list of users.
I’ve included screenshots below to illustrate the setup.
For admins:
For teachers:
Based on this setup, is there a way to implement conditionals directly in the search box (or any other part of the platform) to update the list of users being searched to achieve the desired filtering based on the user’s role?
Any guidance or suggestions would be greatly appreciated!
Thanks in advance for your help!