getRoles() only returning "Admin"

I must be missing something obvious …

Our site provides several places where certain (Admin) functionality is limited to the site owner. We accomplished this via code using getRoles() to determine if the site owner was logged in. If so, then certain parts of the site are made visible. This has been working great.

Recently we added wix bookings to our site. With that, we’ve invited some members to be “Bookings Staff Members” so they can manage their calendars. Sometime after that we received questions that these “Bookings Staff Members” were able to see/access the admin functions of the site.

Turns out, getRoles() for these “Bookings Staff Members” is returning “Admin” as their role.

But, https://www.wix.com/velo/reference/wix-users/user/getroles says “The site owner: The promise resolves to the admin’s roles with an additional role containing the name"Admin”. In this case, a logged in member who is NOT the owner is being identified as “Admin”.

As a workaround I created a new role, “Administrator” and assigned this user to the new role. The user in question now has two roles listed on my site’s Settings->Roles&Permissions page; “Bookings Staff Member” and “Administrator”.

However, on the live site when this user is logged in, getRoles() still returns only “Admin”.

In case you’re wondering, this is the code that is checking the roles of the current user:
let user = wixUsers.currentUser
user.getRoles()
.then( (roles) => {
console.log(roles)
})

Is there any wisdom you can share?

Thx!

I solved my own problem. I was missing something but I’ll contend it wasn’t so obvious …

There are (at least) TWO definitions of “role” in the wix eco-system:

  • first, the one is used under settings->Roles&Permissions (this is where I was originally trying to create a new role to use with getRoles() but it never was reported through that function)

  • second is the one used under CustomerManagement->SiteMembers->MemberPermissions

It is the SECOND one that will appear in the getRoles() promise. Once I discovered this difference and created my new role there, all is once again right in the world of wix.