Search.../

updateGroup( )

Updates a group.

Description

The updateGroup() function returns a Promise that resolves to the updated group. Only site admins and group admins can update their group. Only the fields in the groupInfo object parameter can be updated. Specify which fields to update. Unspecified fields remain the same.

Notes:

  • If the suppressAuth option is set to true, all permissions are overwritten, and all site members (including non-group members) can update a group.
  • When a group's privacyStatus is updated from PRIVATE to PUBLIC, all pending join requests for that group are automatically approved.
  • When a group's privacyStatus is updated from PRIVATE to SECRET, all pending join requests for that group are automatically rejected.
  • When a public or private group's name is updated, the slug is updated to reflect the new group name.

Syntax

function updateGroup(groupId: string, groupInfo: GroupInfoUpdate, [options: Options]): Promise<Group>

updateGroup Parameters

NAME
TYPE
DESCRIPTION
groupId
string

ID of group to update.

groupInfo
GroupInfoUpdate

Group information to update.

options
Optional
Options

Authorization options.

Returns

Return Type:

Promise<Group>
NAME
TYPE
DESCRIPTION
_id
string

Group ID.

name
string

Group name.

slug
string

Part of a group's URL, for example, 'https:/example.com/groups/{my-group-slug}'. Generally based on the group name, but for secret groups it is an autogenerated string of characters, for example, 'https:/example.com/groups/{5D3yTX}'. It is case-sensitive.

description
string

Group description.

privacyStatus
string

Group privacy level. One of:

  • PUBLIC: Site visitors can see the group and its content in the list of groups. Site members can join the group.
  • PRIVATE: Site visitors can see the group in the list of groups, but only group members can see its content. Site members can request to join the group.
  • SECRET: Only group members can see the group and its content in the list of groups. Site members can only join if invited by group admins, or other group members.
coverImage
CoverImage

Group cover image.

memberTitle
string

What group members are called. For example, 'Coworkers', 'Friends', or 'Students'.

memberCount
number

Number of members in the group.

settings
GroupSettings

Group settings.

lastActivityDate
Date

Date and time the group was last active. For example, a post or comment.

_createdDate
Date

Date and time the group was created.

_updatedDate
Date

Date and time the group was last updated.

owner
string

Site member ID of the group creator. Defaults to group creator.

Was this helpful?

Update a group

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { groups } from 'wix-groups-backend';
3
4// Sample groupId value:
5// '83636377-b415-4ebe-ba41-df338c5ad6b7'
6//
7// Sample groupInfo value:
8// {
9// name: 'My Updated Group',
10// description: 'This is my updated group about cats.',
11// }
12
13export const myUpdateGroupFunction = webMethod(Permissions.Anyone, (groupId, groupInfo) => {
14 return groups.updateGroup(groupId, groupInfo)
15 .then((updatedGroup) => {
16 const updatedGroupName = updatedGroup.name;
17 const updatedGroupDescription = updatedGroup.description;
18 return updatedGroup;
19 })
20 .catch((error) => {
21 console.error(error);
22 });
23});
24
25/* Promise resolves to:
26 * {
27 * "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7"
28 * "name": "My Updated Group"
29 * "slug": my-updated-group
30 * "description": "This is my new group about cats."
31 * "privacyStatus": "PUBLIC"
32 * "coverImage": {
33 * "imageUrl": "wix:image://v1/vcc6074e348009011fa9f2d29kk7~mv2.jpg/maple.jpg#originWidth=999&originHeight=240",
34 * "position": {
35 * "x": 30,
36 * "y": 225
37 * }
38 * }
39 * "memberTitle": "Members"
40 * "memberCount": 250
41 * "settings": {
42 * "groupUpdatePostEnabled": true
43 * "membersCanApprove": false
44 * "membersCanInvite": true
45 * "showMemberList": true
46 * "welcomeMemberPostEnabled": true
47 * }
48 * "lastActivityDate": "Wed Nov 29 2021 18:23:23 GMT+0300"
49 * "_createdDate": "Tues Jan 22 2020 12:56:02 GMT+0300"
50 * "_updatedDate": "Wed Nov 29 2021 18:23:23 GMT+0300"
51 * "owner": "9ne8e9e1-d050-4c86-9684-e7f231600a34"
52 * }
53 */
Update a group with more information

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { groups } from 'wix-groups-backend';
3
4// Sample groupId value:
5// '83636377-b415-4ebe-ba41-df338c5ad6b7'
6//
7// Sample groupInfo value:
8// {
9// name: 'My Updated Group',
10// description: 'This is my updated group about cats.',
11// privacyStatus: "PRIVATE"
12// coverImage: {
13// imageUrl: 'wix:image://v1/vcc6074e348009011fa9f2d29kk7~mv2.jpg/maple.jpg#originWidth=999&originHeight=240',
14// position: {
15// x: 30,
16// y: 225
17// }
18// },
19// memberTitle: 'Friends',
20// settings: {
21// groupUpdatePostEnabled: false
22// membersCanApprove: true
23// membersCanInvite: false
24// showMemberList: false
25// welcomeMemberPostEnabled: false
26// }
27// }
28//
29// Sample options value:
30// {
31// suppressAuth: true
32// }
33
34export const myUpdateGroupFunction = webMethod(Permissions.Anyone, (groupId, groupInfo, options) => {
35 return groups.updateGroup(groupId, groupInfo, options)
36 .then((updatedGroup) => {
37 const updatedGroupName = updatedGroup.name;
38 const updatedGroupDescription = updatedGroup.description;
39 return updatedGroup;
40 })
41 .catch((error) => {
42 console.error(error);
43 });
44});
45
46/* Promise resolves to:
47 * {
48 * "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7"
49 * "name": "My Updated Group"
50 * "slug": my-updated-group
51 * "description": "This is my new group about cats."
52 * "privacyStatus": "PRIVATE"
53 * "coverImage": {
54 * "imageUrl": "wix:image://v1/n6p6074e348009011fa9f2d29j~mv2.jpg/salami.jpg#originWidth=227&originHeight=2240",
55 * "position": {
56 * "x": 30,
57 * "y": 225
58 * }
59 * }
60 * "memberTitle": "Friends"
61 * "memberCount": 250
62 * "settings": {
63 * "groupUpdatePostEnabled": false
64 * "membersCanApprove": true
65 * "membersCanInvite": false
66 * "showMemberList": false
67 * "welcomeMemberPostEnabled": false
68 * }
69 * "lastActivityDate": "Wed Nov 29 2021 18:23:23 GMT+0300"
70 * "_createdDate": "Tues Jan 22 2020 12:56:02 GMT+0300"
71 * "_updatedDate": "Wed Nov 29 2021 18:23:23 GMT+0300"
72 * "owner": "9ne8e9e1-d050-4c86-9684-e7f231600a34"
73 * }
74 */