Approves requests to create a group.
Note: This function is only relevant if admin approval is required for creating a group, or if the function's suppressAuth
option is set to true
.
The approveCreateRequests()
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: If the suppressAuth
option is set to true
, all permissions are overwritten, and all site members can approve requests to create a group.
function approveCreateRequests(
createRequestIds: Array<string>,
options: Options,
): Promise<Array<CreateRequest>>;
IDs of the create requests to approve.
Authorization options.
import { Permissions, webMethod } from "wix-web-module";
import { createRequests } from "wix-groups-backend";
// Sample createRequestIds value:
// ['8a3be85ea03e4b8b82f2f9c989557c3d', '6ff5333-b477-4e9tt-ba4j-df338c5ad6221']
//
export const myApproveCreateRequestsFunction = webMethod(
Permissions.Anyone,
async (createRequestIds) => {
try {
const approvedCreateRequests =
await createRequests.approveCreateRequests(createRequestIds);
return approvedCreateRequests;
} catch (error) {
console.error(error);
}
},
);
/* Promise resolves to:
* [
* {
* "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7",
* "status": "APPROVED"
* "group": {
* "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7"
* "name": "My Group Request 1"
* "slug": "my-group-request-1"
* "description": "Welcome to the group! You can connect with other members, get updates and share videos."
* "privacyStatus": "PRIVATE"
* "coverImage": {
* "imageUrl": "wix:image://v1/ff9074e348009011fa9f2d2961b~mv2.jpg/oak.jpg#originWidth=400&originHeight=900",
* "position": {
* "x": 20,
* "y": 25
* }
* }
* "memberTitle": "Friends"
* "memberCount": 1
* "settings": {
* "groupUpdatePostEnabled": true
* "membersCanApprove": false
* "membersCanInvite": true
* "showMemberList": true
* "welcomeMemberPostEnabled": true
* }
* "lastActivityDate": "Sun Sep 26 2021 08:23:23 GMT+0300"
* "_createdDate": "Tues January 22 2021 12:56:02 GMT+0300"
* "_updatedDate": "Fri October 2 2021 04:56:22 GMT+0300"
* "owner": "9ne8e9e1-d050-4c86-9684-e7f231600a34"
* }
* },
* {
* "_id": "6ff5333-b477-4e9tt-ba4j-df338c5ad6221",
* "status": "APPROVED"
* "group": {
* "_id": "6ff5333-b477-4e9tt-ba4j-df338c5ad6221"
* "name": "My Group Request 2"
* "slug": "my-group-request-2"
* "description": "Welcome to the group! You can connect with other members, get updates and share videos."
* "privacyStatus": "PRIVATE"
* "coverImage": {
* "imageUrl": "wix:image://v1/vcc6074e348009011fa9f2d29kk7~mv2.jpg/maple.jpg#originWidth=999&originHeight=240",
* "position": {
* "x": 730,
* "y": 625
* }
* "memberTitle": "Members"
* "memberCount": 30
* "settings": {
* "groupUpdatePostEnabled": true
* "membersCanApprove": true
* "membersCanInvite": true
* "showMemberList": false
* "welcomeMemberPostEnabled": true
* }
* "lastActivityDate": "Thurs Nov 12 2020 11:13:03 GMT+0300"
* "_createdDate": "Wed May 14 2020 10:05:20 GMT+0300",
* "_updatedDate": "Sun June 7 2020 09:07:33 GMT+0300"
* "owner": "abe5e4e1-d950-4c46-8884-e7f231600d67"
* }
* }
* ]
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.