Search.../

listMemberships( )

Lists all group memberships of a site member.

Description

The listMemberships() function returns a Promise that resolves to a list of up to 100 group memberships. Sorts by default to groupId in descending order.

Notes:

  • Only site admins can retrieve a site member's memberships. Site members can see a list of their memberships. However, if the suppressAuth option is set to true, all permissions are overwritten, and all site members (including non-group members) can see a list of a site member's memberships.
  • 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 listMemberships(memberId, paging, null). To specify supressAuth only, call listMemberships(memberId, null, options).

Syntax

function listMemberships(memberId: string, [paging: PagingMemberships], [options: Options]): Promise<ListMemberships>

listMemberships Parameters

NAME
TYPE
DESCRIPTION
memberId
string

Site member ID.

paging
Optional
PagingMemberships

Paging options.

options
Optional
Options

Authorization options.

Returns

Return Type:

Promise<ListMemberships>
NAME
TYPE
DESCRIPTION
memberships
Array<Membership>

Site member's memberships.

metadata
Metadata

Paging information.

Was this helpful?

List all group memberships of a site member

Copy Code
1import { members } from 'wix-groups-backend';
2
3// Sample memberId value:
4// '980bcb7458ea55cf94-bd3a-466d-9'
5
6export function myListMembershipsFunction(memberId) {
7 return members.listMemberships(memberId)
8 .then((groupMembershipsResults) => {
9 const groupMembershipsRole = groupMembershipsResults.memberships[0].role;
10 return groupMembershipsResults;
11 })
12 .catch((error) => {
13 console.error(error);
14 });
15}
16
17/* Promise resolves to:
18 * memberships: [
19 * {
20 * "groupId": "937cd3db-e9be-4980-93c1-a6d767a11050"
21 * "status": "JOINED"
22 * "role": "ADMIN"
23 * },
24 * {
25 * "groupId": "7fe8e9e1-d050-4c86-9684-e7f231600a34"
26 * "status": "PENDING"
27 * "role": "MEMBER"
28 * }
29 * ],
30 * metadata:
31 * {
32 * "length": 2
33 * "tooManyToCount": false
34 * "totalCount": 5
35 * }
36 */
List all group memberships of a site member using options

Copy Code
1import { members } from 'wix-groups-backend';
2
3// Sample memberId value:
4// '980bcb7458ea55cf94-bd3a-466d-9'
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 myListMembershipsFunction(memberId, paging, options) {
18 return members.listMemberships(memberId, paging, options)
19 .then((groupMembershipsResults) => {
20 const groupMembershipsRole = groupMembershipsResults.memberships[0].role;
21 return groupMembershipsResults;
22 })
23 .catch((error) => {
24 console.error(error);
25 });
26}
27
28/* Promise resolves to:
29 * memberships: [
30 * {
31 * "groupId": "937cd3db-e9be-4980-93c1-a6d767a11050"
32 * "status": "JOINED"
33 * "role": "ADMIN"
34 * },
35 * {
36 * "groupId": "7fe8e9e1-d050-4c86-9684-e7f231600a34"
37 * "status": "PENDING"
38 * "role": "MEMBER"
39 * }
40 * ],
41 * metadata:
42 * {
43 * "length": 2
44 * "tooManyToCount": false
45 * "totalCount": 5
46 * }
47 */