Search.../

listGroupMembers( )

Lists all members of a group.

Description

The listGroupMembers() function returns a Promise that resolves to a list of up to 100 group members. Sorts by default to joinedDate in descending order.

Notes:

  • For SECRET groups, only site admins, group admins, and group members can see the list of group members. However, if the suppressAuth option is set to true, all permissions are overwritten, and all site members (including non-group members) can see the list of group members.
  • This function's parameters are positional, and must be specified in the sequence shown in the syntax below. When specifying a parameter, use null as a placeholder for any unspecified parameters. For example, to specify limit only, call listGroupMembers(groupId, paging, null). To specify supressAuth only, call listGroupMembers(groupId, null, options).

Syntax

function listGroupMembers(groupId: string, [paging: Paging], [options: Options]): Promise<ListGroupMembers>

listGroupMembers Parameters

NAME
TYPE
DESCRIPTION
groupId
string

Group ID.

paging
Optional
Paging

Paging options.

options
Optional
Options

Authorization options.

Returns

Return Type:

Promise<ListGroupMembers>
NAME
TYPE
DESCRIPTION
members
Array<GroupMember>

Group members.

metadata
Metadata

Paging information.

Was this helpful?

List all site members in a group

Copy Code
1import { members } from 'wix-groups-backend';
2
3// Sample groupId value:
4// '6355cf94-bd3a-466d-9d61-980bcb7458ea'
5
6export function myListGroupMembersFunction(groupId) {
7 return members.listGroupMembers(groupId)
8 .then((groupMembersResults) => {
9 const groupMembersRole = groupMembersResults.members[0].role;
10 return groupMembersResults;
11 })
12 .catch((error) => {
13 console.error(error);
14 });
15}
16
17/* Promise resolves to:
18 * members: [
19 * {
20 * "role": "ADMIN"
21 * "memberId": "437cd3db-e9be-4980-93c1-a6d767a11050"
22 * "joinedDate": "Sun Aug 01 2021 12:32:35 GMT+0300"
23 * },
24 * {
25 * "role": "MEMBER"
26 * "memberId": "7fe8e9e1-d050-4c86-9684-e7f231600a34"
27 * "joinedDate": "Tues Jun 30 2019 10:09:33 GMT+0300"
28 * }
29 * ],
30 * metadata:
31 * {
32 * "length": 2
33 * "tooManyToCount": false
34 * "totalCount": 5
35 * }
36 */
List all site members in a group using options

Copy Code
1import { members } from 'wix-groups-backend';
2
3// Sample groupId value:
4// '6355cf94-bd3a-466d-9d61-980bcb7458ea'
5//
6// Sample paging value:
7// {
8// limit: 2,
9// skip: 1
10// }
11//
12// Sample options value:
13// {
14// suppressAuth: true
15// }
16
17export function myListGroupMembersFunction(groupId, paging, options) {
18 return members.listGroupMembers(groupId, paging, options)
19 .then((groupMembersResults) => {
20 const groupMembersRole = groupMembersResults.members[0].role;
21 return groupMembersResults;
22 })
23 .catch((error) => {
24 console.error(error);
25 });
26}
27
28/* Promise resolves to:
29 * members: [
30 * {
31 * "role": "ADMIN"
32 * "memberId": "437cd3db-e9be-4980-93c1-a6d767a11050"
33 * "joinedDate": "Sun Aug 01 2021 12:32:35 GMT+0300"
34 * },
35 * {
36 * "role": "MEMBER"
37 * "memberId": "7fe8e9e1-d050-4c86-9684-e7f231600a34"
38 * "joinedDate": "Tues Jun 30 2019 10:09:33 GMT+0300"
39 * }
40 * ],
41 * metadata:
42 * {
43 * "length": 2
44 * "tooManyToCount": false
45 * "totalCount": 5
46 * }
47 */