Hello! I have dabbled in Bubble for a while, but consider myself a “noob” when it comes to creating databases of users, and assigning roles…so here’s my question:
I want to allow one user the ability to login, see a specific element, click a button, which will then change part of the app for everyone to see.
…In more detail: A professor of a research group wants his lab members to know when he is in his office. Can he have the ability to see a specific element, select “Yes” or “No”, which will the alter the way the app looks for everyone else? For example “John Doe is in his office” would appear if he clicks “yes” or “John Doe is not in his office” will appear if he clicks “no”.
I hope this makes sense. Any help would be greatly appreciated!
Make a text field on the user data type, call it role, and set the value to “professor”
Then, on the button, make it visible or clickable ONLY if the current users “role” value is “professor”
This way you can also make more roles using the same text field, if needed in the future. Then make different roles have access to different parts of the app.
Quick followup, and sorry for my ignorance, but how do I change the value to “professor”? I have created user data type of “role”, and I’ve tried to do it in the database, as well as within the element itself. Thank you again!
One more quick question, if you don’t mind! Now that I have made the button viewable to only the “professor” role. If he pushes the button, would it be possible to show a text box for everyone?
For example: He presses “yes” indicating that he’s in his office. I want all users, no matter the role, to see a text box that says “Professor is in his office”. And then when he presses “no” it either goes away, or a new box appears that says “Professor is not in his office”. Is it possible to create something like a “current state” of the app, that is dependent upon him pushing a button, and would remain in place until he pushed the other button (potentially creating a new “state”?
What I like to do for my more advanced apps, is create a data type called “Website” This data type will only have one entry, and only you (the owner) will have access to it. This can function as a “global custom state”.
Do you have more than one professor? You can create a list of users in the “Website” data type. Then when A professor click the button he adds himself to it. Also a button to remove himself from that list.
Then have “something” that only shows when the number of users in the Website’s list of users is more than 0.
This way you can also make it so you can show which professors are online in a list.
I created the data type called “Website”. Do I need to add a custom field to it?
I only have one professor at the moment, but I still think the idea to create a list of users for the “website” data type will work. How would I go about creating the list? I think I can figure out how to make the element reference the list, just not sure how to add and remove something from the list based on the press of a button.
Sorry again for my ignorance! Thanks for the help!