Get User By Role

Hello,
I am creating an admin page on my site, which has the ability to add and remove roles per user. I would like to display all users that have a particular role. Are either of these approaches possible:

  1. Is there a way to get a users role provided their Id?
  2. Is there a way to get a list of all users provided a specific role?

Thanks, Zack

Hey @zackgreenberg ,

  1. https://www.wix.com/velo/reference/wix-members-backend/currentmember/getroles

  2. Do you see a database called “Roles” under the members/users folder? I think you can try to get all users from that referenced users fields.

Certified Code Logo

Hello @certified-code ,
Thanks for the reply.

  1. The page you referenced only shows roles for the currentmember, but in my use case that is not what I am looking for. The currentmember is a site admin, who wants to see the roles of other members. This is needed to see which roles that user has, so the admin can remove / add roles as necessary.

  2. No, I only see Badges, PrivateMembersData, and PublicData.

Maybe you want to use BADGES instead of ROLES?
Example…

Maybe one of the following links can help you…

You will surely find more about this Login-Management-System when using the SEARCH or visiting my PROFILE, to get more info.

https://russian-dima.wixsite.com/login-system/vnloginmgm

Badges will not work as I want to control access to certain pages.

Badges will not work as I am trying to control access to certain pages.

Then BAGES should work too

I thought the whole point of Roles is to control access to pages, and are to give individuals ‘awards’

I would say, you can misuse bagdes, giving every BADGE an individual access / function.
Who has the right BADGE, can enter the right page.

That seems like a poor hack. There is functionality built in for Roles, ie the “you don’t have permission to view this page”. Is there no way to accomplish getting all the site members permissions?

The WIX UI exposes the same functionality I am trying to implement. How does WIX do it?

What you could do is to generate your own additional DATABASE, where you will store every single registrated ROLE, including related ID.

Then use this database to check for IDs and related roles.


I worked once on a similar issue as i can remember (long ago).
So my solution was an additional DATABASE where i have stored all ROLE-DATA (i think).

When you open this site here, you will see the Login-Management-System i am talking about…

https://russian-dima.wixsite.com/login-system/vnloginmgm

Login as —> Mr-President (Login-Access-Data can be found on the top of the site).
Open the CONSOLE and take a look which data you get in the OUTPUT…

Something like…

Also check which data you can get out of PMD (PrivateMembersData), using a query.

And the last options would be…

  1. wixMembers-Backend-API
  2. wixCRM-Backend-API

Check all these options.

To connect the Wix embeded ROLE-MANAGEMENT-SYSTEM with your own, i think this won’t be possible, since as i can remember there is no API existing for it.

This is also the reason, why you can find and EXTERNAL/ADDITIONAL ROLE-MANAGEMENT-SYSTEM integrated into this own created LOGIN-APP…

And because also the out of the box Wix-Badge-System was not enough (not functional enough), my idea was to create my own one…

This way aan own created/expanded “BADGE-GENERATOR” was borned.
And in this case (using) BADGES, you wix gives you enough oppertunities and API-functions to implement and connect it to the wix-standard BADGE-MANAGEMENT, which you normaly can manage inside your WIX-DASHBOARD

The Wix out of the box standard BAGDE-MANAGEMENT…

Hi @certified-code
where should I see this “Roles” database exactly? In my collections I see only “badges”, “PrivateMembersData” and “PublicData” under “Members”. Or should I be looking elsewhere?
I find it strange that wix-members-backend Members API doesn’t have a GetRoles(ID) function. Any reason?

cheers

Mark

Roles have a badge in the backend so you can use badge.listMembers to do what you are asking: