Search.../

assignRole( )

Assigns a 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 unassigns their admin role.

Syntax

function assignRole(identifiers: Identifiers, role: string, [options: Options]): Promise<Role>

assignRole Parameters

NAME
TYPE
DESCRIPTION
identifiers
Identifiers

Group ID and member IDs.

role
string

Group member role to assign. One of:

  • "MEMBER": Group member.
  • "ADMIN": Group admin.
options
Optional
Options

Authorization options.

Returns

Return Type:

Promise<Role>
NAME
TYPE
DESCRIPTION
role
string

Group member role. One of:

  • "MEMBER": Group member.
  • "ADMIN": Group admin.

Was this helpful?

Assign a role to a group member

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { roles } from 'wix-groups-backend';
3
4export const assignRole = webMethod(Permissions.Anyone, (identifiers, role, options) => {
5 return roles.assignRole(identifiers, role, options)
6 .then((response) => {
7 console.log(response);
8 })
9 .catch((error) => {
10 console.error(error);
11 });
12});
13
14/* Promise resolves to:
15 * role: "ADMIN"
16 */