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 totrue
, all permissions are overwritten, and all site members (including non-group members) can update a group.- When a group's
privacyStatus
is updated fromPRIVATE
toPUBLIC
, all pending join requests for that group are automatically approved.- When a group's
privacyStatus
is updated fromPRIVATE
toSECRET
, 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
ID of group to update.
Group information to update.
Authorization options.
Returns
Return Type:
NAME
TYPE
DESCRIPTION
Group ID.
Group name.
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.
Group description.
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.
Group cover image.
What group members are called. For example, 'Coworkers', 'Friends', or 'Students'.
Number of members in the group.
Group settings.
Date and time the group was last active. For example, a post or comment.
Date and time the group was created.
Date and time the group was last updated.
Site member ID of the group creator. Defaults to group creator.
Was this helpful?
1import { Permissions, webMethod } from 'wix-web-module';2import { groups } from 'wix-groups-backend';34// 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// }1213export 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});2425/* Promise resolves to:26 * {27 * "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7"28 * "name": "My Updated Group"29 * "slug": my-updated-group30 * "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": 22537 * }38 * }39 * "memberTitle": "Members"40 * "memberCount": 25041 * "settings": {42 * "groupUpdatePostEnabled": true43 * "membersCanApprove": false44 * "membersCanInvite": true45 * "showMemberList": true46 * "welcomeMemberPostEnabled": true47 * }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 */
1import { Permissions, webMethod } from 'wix-web-module';2import { groups } from 'wix-groups-backend';34// 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: 22517// }18// },19// memberTitle: 'Friends',20// settings: {21// groupUpdatePostEnabled: false22// membersCanApprove: true23// membersCanInvite: false24// showMemberList: false25// welcomeMemberPostEnabled: false26// }27// }28//29// Sample options value:30// {31// suppressAuth: true32// }3334export 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});4546/* Promise resolves to:47 * {48 * "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7"49 * "name": "My Updated Group"50 * "slug": my-updated-group51 * "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": 22558 * }59 * }60 * "memberTitle": "Friends"61 * "memberCount": 25062 * "settings": {63 * "groupUpdatePostEnabled": false64 * "membersCanApprove": true65 * "membersCanInvite": false66 * "showMemberList": false67 * "welcomeMemberPostEnabled": false68 * }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 */