Search.../

approveGroupRequests( )

Developer Preview

Approves requests to create a group.

Description

The approveGroupRequests() function returns a Promise that resolves when a site member's request to create a group is approved. Only site admins can approve requests to create a group. When the request is approved, the new group is added to the Groups List page of your site.

Note: This function is only relevant if admin approval is required for creating a group.

Admin Method

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

Syntax

function approveGroupRequests(groupRequestIds: Array<string>): Promise<ApproveGroupRequestsResponse>

approveGroupRequests Parameters

NAME
TYPE
DESCRIPTION
groupRequestIds
Array<
string
>

IDs of the requests create groups to approve.

Max: 100 create group request IDs

Returns

Return Type:

Promise<
ApproveGroupRequestsResponse
>
NAME
TYPE
DESCRIPTION
groupRequest
Array<
GroupRequest
>

Approved request to create a group.

Was this helpful?

Approve a request to create a group (dashboard page code)

Copy Code
1import { createRequests } from 'wix-groups.v2';
2
3// Sample groupRequestIds value:
4// ['8a3be85ea03e4b8b82f2f9c989557c3d', '6ff5333-b477-4e9tt-ba4j-df338c5ad6221']
5//
6
7export function myApproveGroupRequestsFunction(groupRequestIds) {
8 return createRequests.approveGroupRequests(groupRequestIds)
9 .then((approvedGroupRequests) => {
10 return approvedGroupRequests;
11 })
12 .catch((error) => {
13 console.error(error);
14 });
15}
16
17/* Promise resolves to:
18 * {
19 * "groupRequest": [
20 * {
21 * "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7",
22 * "status": "APPROVED",
23 * "group": {
24 * "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7",
25 * "name": "My Group Request 1",
26 * "slug": "my-group-request-1",
27 * "description": "Welcome to the group! You can connect with other members, get updates and share videos.",
28 * "privacyStatus": "PRIVATE",
29 * "coverImage": {
30 * "imageUrl": "wix:image://v1/ff9074e348009011fa9f2d2961b~mv2.jpg/oak.jpg#originWidth=400&originHeight=900",
31 * "position": {
32 * "x": 20,
33 * "y": 25
34 * }
35 * }
36 * "memberTitle": "Friends",
37 * "memberCount": 1,
38 * "settings": {
39 * "groupDetailsChangedPostEnabled": true,
40 * "membersCanApprove": false,
41 * "membersCanInvite": true,
42 * "showMemberList": true,
43 * "welcomeMemberPostEnabled": true
44 * }
45 * "lastActivityDate": "Sun Sep 26 2021 08:23:23 GMT+0300",
46 * "_createdDate": "Tues January 22 2021 12:56:02 GMT+0300",
47 * "_updatedDate": "Fri October 2 2021 04:56:22 GMT+0300",
48 * "owner": "9ne8e9e1-d050-4c86-9684-e7f231600a34"
49 * }
50 * },
51 * {
52 * "_id": "6ff5333-b477-4e9tt-ba4j-df338c5ad6221",
53 * "status": "APPROVED",
54 * "group": {
55 * "_id": "6ff5333-b477-4e9tt-ba4j-df338c5ad6221",
56 * "name": "My Group Request 2",
57 * "slug": "my-group-request-2",
58 * "description": "Welcome to the group! You can connect with other members, get updates and share videos.",
59 * "privacyStatus": "PRIVATE",
60 * "coverImage": {
61 * "imageUrl": "wix:image://v1/vcc6074e348009011fa9f2d29kk7~mv2.jpg/maple.jpg#originWidth=999&originHeight=240",
62 * "position": {
63 * "x": 730,
64 * "y": 625
65 * },
66 * "memberTitle": "Members",
67 * "memberCount": 30,
68 * "settings": {
69 * "groupDetailsChangesPostEnabled": true,
70 * "membersCanApprove": true,
71 * "membersCanInvite": true,
72 * "showMemberList": false,
73 * "welcomeMemberPostEnabled": true
74 * },
75 * "lastActivityDate": "Thurs Nov 12 2020 11:13:03 GMT+0300",
76 * "_createdDate": "Wed May 14 2020 10:05:20 GMT+0300",
77 * "_updatedDate": "Sun June 7 2020 09:07:33 GMT+0300",
78 * "owner": "abe5e4e1-d950-4c46-8884-e7f231600d67",
79 * }
80 * }
81 * ]
82 * }
83 */
Approve a request to create a group (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { createRequests } from 'wix-groups.v2';
3
4// Sample groupRequestIds value:
5// ['8a3be85ea03e4b8b82f2f9c989557c3d', '6ff5333-b477-4e9tt-ba4j-df338c5ad6221']
6//
7
8export const myApproveGroupRequestsFunction = webMethod(Permissions.Anyone, async (groupRequestIds) => {
9 try {
10 const approvedGroupRequests = await createRequests.approveGroupRequests(groupRequestIds);
11 return approvedGroupRequests;
12 } catch (error) {
13 console.error(error);
14 }
15});
16
17/* Promise resolves to:
18 * {
19 * "groupRequest": [
20 * {
21 * "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7",
22 * "status": "APPROVED",
23 * "group": {
24 * "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7",
25 * "name": "My Group Request 1",
26 * "slug": "my-group-request-1",
27 * "description": "Welcome to the group! You can connect with other members, get updates and share videos.",
28 * "privacyStatus": "PRIVATE",
29 * "coverImage": {
30 * "imageUrl": "wix:image://v1/ff9074e348009011fa9f2d2961b~mv2.jpg/oak.jpg#originWidth=400&originHeight=900",
31 * "position": {
32 * "x": 20,
33 * "y": 25
34 * }
35 * }
36 * "memberTitle": "Friends",
37 * "memberCount": 1,
38 * "settings": {
39 * "groupDetailsChangedPostEnabled": true,
40 * "membersCanApprove": false,
41 * "membersCanInvite": true,
42 * "showMemberList": true,
43 * "welcomeMemberPostEnabled": true
44 * }
45 * "lastActivityDate": "Sun Sep 26 2021 08:23:23 GMT+0300",
46 * "_createdDate": "Tues January 22 2021 12:56:02 GMT+0300",
47 * "_updatedDate": "Fri October 2 2021 04:56:22 GMT+0300",
48 * "owner": "9ne8e9e1-d050-4c86-9684-e7f231600a34"
49 * }
50 * },
51 * {
52 * "_id": "6ff5333-b477-4e9tt-ba4j-df338c5ad6221",
53 * "status": "APPROVED",
54 * "group": {
55 * "_id": "6ff5333-b477-4e9tt-ba4j-df338c5ad6221",
56 * "name": "My Group Request 2",
57 * "slug": "my-group-request-2",
58 * "description": "Welcome to the group! You can connect with other members, get updates and share videos.",
59 * "privacyStatus": "PRIVATE",
60 * "coverImage": {
61 * "imageUrl": "wix:image://v1/vcc6074e348009011fa9f2d29kk7~mv2.jpg/maple.jpg#originWidth=999&originHeight=240",
62 * "position": {
63 * "x": 730,
64 * "y": 625
65 * },
66 * "memberTitle": "Members",
67 * "memberCount": 30,
68 * "settings": {
69 * "groupDetailsChangesPostEnabled": true,
70 * "membersCanApprove": true,
71 * "membersCanInvite": true,
72 * "showMemberList": false,
73 * "welcomeMemberPostEnabled": true
74 * },
75 * "lastActivityDate": "Thurs Nov 12 2020 11:13:03 GMT+0300",
76 * "_createdDate": "Wed May 14 2020 10:05:20 GMT+0300",
77 * "_updatedDate": "Sun June 7 2020 09:07:33 GMT+0300",
78 * "owner": "abe5e4e1-d950-4c46-8884-e7f231600d67",
79 * }
80 * }
81 * ]
82 * }
83 */
84