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.

Note: Only site admins can retrieve a site member's memberships. Site members can see a list of their memberships.

Admin Method

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

Syntax

function listMemberships(memberId: string, options: ListMembershipsOptions): Promise<ListMembershipsResponse>

listMemberships Parameters

NAME
TYPE
DESCRIPTION
memberId
string

Site member ID.

options
Optional
ListMembershipsOptions

Paging options.

Returns

Return Type:

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

Site member's memberships.

metadata
PagingMetadata

Paging information.

Was this helpful?

List all group memberships of a site member

Copy Code
1
2import { members } from 'wix-groups.v2';
3
4// Sample memberId value: '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 * "role": {"value": "ADMIN"}
22 * "status": "JOINED"
23 * },
24 * {
25 * "groupId": "7fe8e9e1-d050-4c86-9684-e7f231600a34"
26 * "role": {"value": "MEMBER"}
27 * "status": "PENDING"
28 * },
29 * {
30 * "groupId": "6de7e9e1-f242-3a12-5231-f8e1242c8912"
31 * "role": {"value": "MEMBER"}
32 * "status": "PENDING"
33 * }
34 * ],
35 * metadata:
36 * {
37 * "count": 3
38 * "offset": 0
39 * "tooManyToCount": false
40 * "total": 3
41 * }
42 */
List some of the group memberships of a site member using paging options

Copy Code
1
2import { members } from 'wix-groups.v2';
3
4// Sample groupId value: '6355cf94-bd3a-466d-9d61-980bcb7458ea'
5//
6// Sample options value:
7// {
8// limit: 2
9// offset: 1
10// }
11
12async function listMemberships(memberId, options) {
13 try {
14 const result = await members.listMemberships(memberId, options);
15 return result;
16 } catch (error) {
17 console.error(error);
18 // Handle the error
19 }
20 }
21
22/* Promise resolves to:
23 * members: [
24 * {
25 * "role": "ADMIN"
26 * "memberId": "437cd3db-e9be-4980-93c1-a6d767a11050"
27 * "joinedDate": "Sun Aug 01 2021 12:32:35 GMT+0300"
28 * },
29 * {
30 * "role": "MEMBER"
31 * "memberId": "7fe8e9e1-d050-4c86-9684-e7f231600a34"
32 * "joinedDate": "Tues Jun 30 2019 10:09:33 GMT+0300"
33 * }
34 * ],
35 * metadata:
36 * {
37 * "count": 2
38 * "offset": 1
39 * "tooManyToCount": false
40 * "total": 5
41 * }
42 */