createGroup( )
Creates a group.
Description
The createGroup()
function returns a Promise that resolves to a newly-created group after it has successfully been created. The new group is added to the Groups List page of your site.
Site admins can choose to allow site members to create a group. They can also require that site members request their approval when creating a group.
This setting can be found in your site's Dashboard under Groups Application > General Settings > Group Creation. If set to admin approval required,
a site member uses this function to create a group, and the group becomes a createRequest
with a status of PENDING
until the group is reviewed.
The default is set to site members with admin approval.
Note: If the
suppressAuth
option is set totrue
, all permissions are overwritten, and all site members can create a group.
About the owner
Parameter
- The
owner
parameter in thegroupInfo
object is optional. - If the
owner
parameter is not specified, the value defaults to the site member ID of the creator of the group. - If the
suppressAuth
option is set totrue
, you must specifiy theowner
parameter.suppressAuth
works by removing the identity of an owner, and so it needs an identified owner to remove.
Syntax
function createGroup(groupInfo: GroupInfo, [options: Options]): Promise<Group>
createGroup Parameters
NAME
TYPE
DESCRIPTION
Group to create.
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 groupInfo value:5// {6// name: 'My New Group'7// }89export const myCreateGroupFunction = webMethod(Permissions.Anyone, (groupInfo) => {10 return groups.createGroup(groupInfo)11 .then((createdGroup) => {12 const createdGroupName = createdGroup.name;13 return createdGroup;14 })15 .catch((error) => {16 console.error(error);17 });18});1920/* Promise resolves to:21 * {22 * "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7"23 * "name": "My New Group"24 * "slug": "my-new-group"25 * "description": "Welcome to the group! You can connect with other members, get updates and share videos."26 * "privacyStatus": "PUBLIC"27 * "memberCount": 128 * "settings": {29 * "groupUpdatePostEnabled": true30 * "membersCanApprove": false31 * "membersCanInvite": true32 * "showMemberList": true33 * "welcomeMemberPostEnabled": true34 * }35 * "lastActivityDate": "Tues Jan 22 2020 12:56:02 GMT+0300"36 * "_createdDate": "Tues Jan 22 2020 12:56:02 GMT+0300"37 * "owner": "22nvc8888c7931b4946a3db3"38 * }39 */
1import { Permissions, webMethod } from 'wix-web-module';2import { groups } from 'wix-groups-backend';34// Sample groupInfo value:5// {6// name: 'My Group',7// description: 'This is my group about dogs.',8// privacyStatus: 'PRIVATE',9// coverImage: {10// imageUrl: "wix:image://v1/ff9074e348009011fa9f2d2961b~mv2.jpg/oak.jpg#originWidth=400&originHeight=900",11// position: {12// x: 35,13// y: 014// }15// },16// memberTitle: 'Friends',17// settings: {18// membersCanInvite: true,19// membersCanApprove: true,20// welcomeMemberPostEnabled: true,21// groupUpdatePostEnabled: true,22// showMemberList: true23// },24// owner: '22nvc8888c7931b4946a3db3'25// }26//27// Sample options value:28// {29// suppressAuth: true30// }3132export const myCreateGroupFunction = webMethod(Permissions.Anyone, (groupInfo, options) => {33 return groups.createGroup(groupInfo, options)34 .then((createdGroup) => {35 const createdGroupName = createdGroup.name;36 const createdGroupDescription = createdGroup.description;37 return createdGroup;38 })39 .catch((error) => {40 console.error(error);41 });42});4344/* Promise resolves to:45 * {46 * "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7"47 * "name": "My Group"48 * "slug": "my-group"49 * "description": "This is my group about dogs."50 * "privacyStatus": "PRIVATE"51 * "coverImage": {52 * "imageUrl": "wix:image://v1/ff9074e348009011fa9f2d2961b~mv2.jpg/oak.jpg#originWidth=400&originHeight=900",53 * "position": {54 * "x": 35,55 * "y": 056 * }57 * "memberTitle": "Friends"58 * "memberCount": 159 * "settings": {60 * "membersCanInvite": true,61 * "membersCanApprove": true,62 * "welcomeMemberPostEnabled": true,63 * "groupUpdatePostEnabled": true,64 * "showMemberList": true65 * }66 * "lastActivityDate": "Sun Sep 26 2021 08:23:23 GMT+0300"67 * "_createdDate": "Sun Sep 26 2021 08:23:23 GMT+0300"68 * "_updatedDate": "Tues Sep 28 2021 18:34:25 GMT+0300"69 * "owner": "22nvc8888c7931b4946a3db3"70 * }71 */