Limited Time Offer: Watch All Our Bubble Tutorial Videos for Only $99 per Year!

How to create multiple user types or user roles in Bubble

In this tutorial we explain how to set up multiple user types or user roles in your Bubble app using Option Sets.

Here's a really quick video in which I'll describe what I think is the best way to handle multiple user types or user roles in Bubble.

Avoid creating another data type

So I'm building a marketplace app here in this series of tutorials and if I go into data, what I've seen a lot of users do is that they create a new data type. So they might assume that this user is like the shopper and then if they wanted to create a seller, they created a new data type here called Seller.

That's not a great idea because in Bubble the user data type is special compared to any other data types that you create. Only the user data type is able to have the registration, the login, and the kind of my account functions the other data types don't. So all of your fields to do with users, whether they're sellers or buyers, in this case, need to be part of the user data type.

Labeling your fields based on User role

Something that I often do is I label my fields in a way that distinguishes whether the field is uniquely one role or the other. So for example, if I wanted to create a seller field, I might label it Seller and then put the field name in obviously fields like first name that's going to apply to both sellers and buyers in the context of my marketplace app.

Using an Option Set

So how would I distinguish in my Bubble app between the two roles? Well, this is the perfect use of an Options Set.

So I'm going to create an Option Set called User role and then my two roles are Buyer and Seller. You can also add in I'm working on an app at the moment where Admin is an appropriate role in here because I want to give certain users access to certain areas of my app. So that's another way you could use this Option Set.

Option Set: Single or List

Then in data types I create a new field for user, user role and then I'm faced of a choice and this will really depend on the type of app you're building. Do you want your user to just be one role and then if they change role they kind of go from one bucket into another bucket? Or in this marketplace API, what if I have someone who first of all is a buyer and then they also want to be a seller? I'm thinking along the lines of like an Etsy account or an Ebay account allows you to do both. But there might be some instances where you just want an account to only be one type. But if you want it to be multiple, you can use the list feature here.

Adding the User role Option Set to registration workflows

Great. So if we go onto my frontend, give it a refresh, I have a sign up Group Focus here and then when the user clicks register, it's going to register them. But if I want to make this only for buyers. Then I can add in the User role as Buyer and then I can build a separate registration workflow because I have many fields that are different just for my sellers and sellers I can add them as a buyer and or add them as a seller at the same time.

This also by using as a list this allows me to easily transition someone who's already got an account the email address is in my database from a buyer to a seller.

Latest videos