Search.../

addGroupMembers( )

Adds site members to a group.

Description

The addGroupMembers() function returns a Promise that resolves to the newly-added group member after the member has successfully been added.

For SECRET groups, site admins, group admins, and group members can add additional members to their group.

For PUBLIC and PRIVATE groups, only site admins and group admins can add additional members to their group. They can also choose to allow all group members to add a new member to the group. This setting can be found in your site's Dashboard under Groups Application > Your Group > Admin Tools > Member Permissions.

Note: If the suppressAuth option is set to true, all permissions are overwritten and all site members (including non-group members) can add additional members to a group.

Syntax

function addGroupMembers(identifiers: IdentifiersAddGroupMembers, [options: Options]): Promise<GroupMember>

addGroupMembers Parameters

NAME
TYPE
DESCRIPTION
identifiers
IdentifiersAddGroupMembers

Group ID and member IDs.

options
Optional
Options

Authorization options.

Returns

Return Type:

Promise<GroupMember>
NAME
TYPE
DESCRIPTION
role
string

Group member role. One of:

  • "MEMBER": Group member.
  • "ADMIN": Group admins.
memberId
string

Site member ID of group member.

joinedDate
Date

Date and time the group member joined the group.

Was this helpful?

Add site members to a group

Copy Code
1import { members } from 'wix-groups-backend';
2
3// Sample identifiers value:
4// {
5// groupId: '0261a737-2361-4468-a3b1-5ec2b0667836',
6// memberIds: ['937cd3db-e9be-4980-93c1-a6d767a11050', '7fe8e9e1-d050-4c86-9684-e7f231600a34']
7// }
8//
9// Sample options value:
10// {
11// suppressAuth: true
12// }
13
14export function myAddGroupMembersFunction(identifiers, options) {
15 return members.addGroupMembers(identifiers, options)
16 .then((addedGroupMembers) => {
17 return addedGroupMembers;
18 })
19 .catch((error) => {
20 console.error(error);
21 });
22}
23
24/* Promise resolves to:
25 * [
26 * {
27 * "role": "ADMIN"
28 * "memberId": "437cd3db-e9be-4980-93c1-a6d767a11050"
29 * "joinedDate": "Sun Aug 01 2021 12:32:35 GMT+0300"
30 * },
31 * {
32 * "role": "MEMBER"
33 * "memberId": "7fe8e9e1-d050-4c86-9684-e7f231600a34"
34 * "joinedDate": "Tues Jun 30 2019 10:09:33 GMT+0300"
35 * }
36 * ]
37 */