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 { Permissions, webMethod } from 'wix-web-module';
2import { groups } from 'wix-groups-backend';
3
4// Sample groupInfo value:
5// {
6// name: 'My New Group'
7// }
8
9export 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});
19
20/* 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": 1
28 * "settings": {
29 * "groupUpdatePostEnabled": true
30 * "membersCanApprove": false
31 * "membersCanInvite": true
32 * "showMemberList": true
33 * "welcomeMemberPostEnabled": true
34 * }
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 */
Create a group with more information

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { groups } from 'wix-groups-backend';
3
4// 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: 0
14// }
15// },
16// memberTitle: 'Friends',
17// settings: {
18// membersCanInvite: true,
19// membersCanApprove: true,
20// welcomeMemberPostEnabled: true,
21// groupUpdatePostEnabled: true,
22// showMemberList: true
23// },
24// owner: '22nvc8888c7931b4946a3db3'
25// }
26//
27// Sample options value:
28// {
29// suppressAuth: true
30// }
31
32export 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});
43
44/* 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": 0
56 * }
57 * "memberTitle": "Friends"
58 * "memberCount": 1
59 * "settings": {
60 * "membersCanInvite": true,
61 * "membersCanApprove": true,
62 * "welcomeMemberPostEnabled": true,
63 * "groupUpdatePostEnabled": true,
64 * "showMemberList": true
65 * }
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 */