Search.../

assignRole( )

Assigns a specific role to group members.

Description

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.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function assignRole(groupId: string, memberIds: Array<string>, role: GroupRole): Promise<AssignRoleResponse>

assignRole Parameters

NAME
TYPE
DESCRIPTION
groupId
string

Group ID.

memberIds
Array<
string
>

Member IDs.

Max: 100 member IDs

role
GroupRole

Role to assign.

Returns

Return Type:

Promise<
AssignRoleResponse
>
NAME
TYPE
DESCRIPTION
groupId
string

Group ID.

memberIds
Array<
string
>

Member IDs

role
GroupRole

Assigned role.

Was this helpful?

Assign a role to a group member

Copy Code
1import { roles } from "wix-groups.v2";
2
3// Sample ID values:
4// memberIds: ['7fe8e9e1-d050-4c86-9684-e7f231600a34'],
5// groupId: '0261a737-2361-4468-a3b1-5ec2b0667836.'
6//
7// Sample role value:
8// role: 'ADMIN'
9//
10
11
12export function assignRole(groupId, memberIds, role) {
13 return roles.assignRole(groupId, memberIds, role)
14 .then((response) => {
15 console.log(response);
16 })
17 .catch((error) => {
18 console.error(error);
19 });
20}
21
22/* Promise resolves to:
23 * role: "ADMIN"
24 */