Search.../

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 to true, all permissions are overwritten, and all site members can create a group.

About the owner Parameter

  • The owner parameter in the groupInfo 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 to true, you must specifiy the owner 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
groupInfo
GroupInfo

Group to create.

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?

Create a group

Copy Code
1import { groups } from 'wix-groups-backend';
2
3// Sample groupInfo value:
4// {
5// name: 'My New Group'
6// }
7
8export function myCreateGroupFunction(groupInfo) {
9 return groups.createGroup(groupInfo)
10 .then((createdGroup) => {
11 const createdGroupName = createdGroup.name;
12 return createdGroup;
13 })
14 .catch((error) => {
15 console.error(error);
16 });
17}
18
19/* Promise resolves to:
20 * {
21 * "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7"
22 * "name": "My New Group"
23 * "slug": "my-new-group"
24 * "description": "Welcome to the group! You can connect with other members, get updates and share videos."
25 * "privacyStatus": "PUBLIC"
26 * "memberCount": 1
27 * "settings": {
28 * "groupUpdatePostEnabled": true
29 * "membersCanApprove": false
30 * "membersCanInvite": true
31 * "showMemberList": true
32 * "welcomeMemberPostEnabled": true
33 * }
34 * "lastActivityDate": "Tues Jan 22 2020 12:56:02 GMT+0300"
35 * "_createdDate": "Tues Jan 22 2020 12:56:02 GMT+0300"
36 * "owner": "22nvc8888c7931b4946a3db3"
37 * }
38 */
Create a group with more information

Copy Code
1import { groups } from 'wix-groups-backend';
2
3// Sample groupInfo value:
4// {
5// name: 'My Group',
6// description: 'This is my group about dogs.',
7// privacyStatus: 'PRIVATE',
8// coverImage: {
9// imageUrl: "wix:image://v1/ff9074e348009011fa9f2d2961b~mv2.jpg/oak.jpg#originWidth=400&originHeight=900",
10// position: {
11// x: 35,
12// y: 0
13// }
14// },
15// memberTitle: 'Friends',
16// settings: {
17// membersCanInvite: true,
18// membersCanApprove: true,
19// welcomeMemberPostEnabled: true,
20// groupUpdatePostEnabled: true,
21// showMemberList: true
22// },
23// owner: '22nvc8888c7931b4946a3db3'
24// }
25//
26// Sample options value:
27// {
28// suppressAuth: true
29// }
30
31export function myCreateGroupFunction(groupInfo, options) {
32 return groups.createGroup(groupInfo, options)
33 .then((createdGroup) => {
34 const createdGroupName = createdGroup.name;
35 const createdGroupDescription = createdGroup.description;
36 return createdGroup;
37 })
38 .catch((error) => {
39 console.error(error);
40 });
41}
42
43/* Promise resolves to:
44 * {
45 * "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7"
46 * "name": "My Group"
47 * "slug": "my-group"
48 * "description": "This is my group about dogs."
49 * "privacyStatus": "PRIVATE"
50 * "coverImage": {
51 * "imageUrl": "wix:image://v1/ff9074e348009011fa9f2d2961b~mv2.jpg/oak.jpg#originWidth=400&originHeight=900",
52 * "position": {
53 * "x": 35,
54 * "y": 0
55 * }
56 * "memberTitle": "Friends"
57 * "memberCount": 1
58 * "settings": {
59 * "membersCanInvite": true,
60 * "membersCanApprove": true,
61 * "welcomeMemberPostEnabled": true,
62 * "groupUpdatePostEnabled": true,
63 * "showMemberList": true
64 * }
65 * "lastActivityDate": "Sun Sep 26 2021 08:23:23 GMT+0300"
66 * "_createdDate": "Sun Sep 26 2021 08:23:23 GMT+0300"
67 * "_updatedDate": "Tues Sep 28 2021 18:34:25 GMT+0300"
68 * "owner": "22nvc8888c7931b4946a3db3"
69 * }
70 */