Was this helpful?
Yes
No

Setup

To use the Roles API, install the @wix/groups package using npm or Yarn:

Copy
1
npm install @wix/groups

or

Copy
1
yarn add @wix/groups

Then import { roles } from @wix/groups:

Copy
1
import { roles } from '@wix/groups'
Was this helpful?
Yes
No

assignRole( )

Assigns a specific role to group members.

Note: This function is only relevant for site admins, and group members with group admin permissions.

The assignRole() function returns a Promise that resolves to the newly-assigned role after it has successfully been assigned. Assigning a role overrides an existing role. For example, assigning a member role to an admin unassigned their admin role.

Copy
function assignRole(groupId: string, memberIds: Array<string>, role: GroupRole, options: AssignRoleOptions): Promise<AssignRoleResponse>
Method Parameters
groupIdstringRequired
Group ID.

memberIdsArray<string>Required
Member IDs. Max: 100 member IDs

roleGroupRoleRequired
Role to assign.

optionsAssignRoleOptions
Returns
Return Type:Promise<AssignRoleResponse>
Was this helpful?
Yes
No

unassignRole( )

Unassigns a role from group members.

Note: This function is only relevant for site admins, and group members with group admin permissions.

The unassignRole() function returns a Promise that resolves to the unassigned role after it has successfully been unassigned. This function only applies to admin roles. Using this function with member roles returns an error.

Copy
function unassignRole(groupId: string, memberIds: Array<string>, role: GroupRole, options: UnassignRoleOptions): Promise<UnassignRoleResponse>
Method Parameters
groupIdstringRequired
Group ID.

memberIdsArray<string>Required
Member IDs. Max: 100 member IDs

roleGroupRoleRequired
Role to unassign.

optionsUnassignRoleOptions
Returns
Return Type:Promise<UnassignRoleResponse>
Was this helpful?
Yes
No