Have an option set for the menu items…then on that option set add a new attribute and make it the option set for user role…then you can setup a RG with menu items and filter by the user role attribute
Yes, using option sets for your menu items will be faster…
Here’s how I do it…
create an option set for your user roles, and add the options (e.g. Admin, Creator, User etc.). Add whatever attributes you need to the option set (as you would with database fields). Make sure to add this as a field on your User datatype, and set each User’s value.
Create an option set for your menu items, and add your options. Have an attribute on this option set called something like ‘User Role Access’, set it to the type of your ‘User Roles’ option set, and make it a list.
Set the ‘User Role Access’ attribute on each Menu Item to contain whichever User Roles you want to have access to that menu item.
Then, create a RG on your page with content type Menu Items (your option set) with a datasource of ‘All Menu Items’: filtered: User Role Access contains Current User’s User Role.
That will show only the Menu items’ who’s defined user roles contains the current user’s user role.
(note this only works if a user can only have a single user role. If a user can have multiple user roles you’ll need to use ‘intersect with: count >0’ instead of ‘Contains’.)
To me it seems like the best option so far, but I am not bubble master just yet lol haha. One question - will it slow down my app considerably or not? someone in another group said it’s better to have as many RGs as I have user roles and show those groups depending on user roles?
I don’t see why it should. Maybe if you had hundreds or thousands of menu items and user roles it might - but I’ve never experienced any slowness using that method on my apps with a handful of user roles, and half a dozen or so menu items. And using option sets instead of database entries, and relating everything to the current user, should be fast as there’s no searching of the database.
But there are always multiple approaches to the same problem though, so having one RG with conditional datasources, or multiple RGs, are all valid options.
The best thing is to try one and see how it works - if it doesn’t work well for your app then try an alternative and see how it compares.
thank you very much for explaining it to me and your help, Adam! What you saying does make a lot of sense + you tested it yourself so that’s great. I agree everything can be done in a lot of diff ways in bubble!
Your option seems more logical to me as doesn’t require making 3 RGs with seems excessive and hard to maintain, trying to do the least possible work as a principle here