> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # AddGroupMembers # Package: memberManagement # Namespace: GroupMembersService # Method link: https://dev.wix.com/docs/api-reference/crm/community/groups/member-management/members/add-group-members.md ## Introduction Add site members to a specific group. Public members are added right away, while private members receive an invitation to join the group. For `SECRET` groups, group admins and group members can add additional members to their group. For `PUBLIC` and `PRIVATE` groups, only group admins can add additional members to their group. They can also allow all group members to add a new member to the group with `group.settings`. --- ## REST API ### Schema ``` Method: addGroupMembers Description: Add site members to a specific group. Public members are added right away, while private members receive an invitation to join the group. For `SECRET` groups, group admins and group members can add additional members to their group. For `PUBLIC` and `PRIVATE` groups, only group admins can add additional members to their group. They can also allow all group members to add a new member to the group with `group.settings`. URL: https://www.wixapis.com/v2/groups/{groupId}/members Method: POST Method parameters: param name: memberIds | type: array | description: Member GUIDs. See the Members API for details. Return type: AddGroupMembersResponse - name: members | type: array | description: New members. - name: memberId | type: string | description: Member GUID. See the Members API for more details. - name: role | type: GroupRole | description: Group member role. - name: value | type: Role | description: Member's role. - enum: - MEMBER: Regular group member. - ADMIN: Group administrator. - name: joinedDate | type: string | description: Date and time the group Member joined the group. ``` ### Examples ### AddGroupMembers ```curl ~~~cURL curl -X POST \ https://wixapis.com/social-groups/v2/groups/a4caf853-c0d7-498e-8eaa-3db36522dcbf/members \ -H 'Content-Type: application/json;charset=UTF-8' \ -H 'Authorization: ' -d '{ "siteMemberIds": [ "e6674661-f294-4f1f-9f22-bc11fa8164e7" ] }' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.memberManagement.GroupMembersService.addGroupMembers(groupId, memberIds) Description: Add site members to a specific group. Public members are added right away, while private members receive an invitation to join the group. For `SECRET` groups, group admins and group members can add additional members to their group. For `PUBLIC` and `PRIVATE` groups, only group admins can add additional members to their group. They can also allow all group members to add a new member to the group with `group.settings`. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: groupId, memberIds Method parameters: param name: groupId | type: string | description: Group GUID. | required: true param name: memberIds | type: array | description: Member GUIDs. See the Members API for details. | required: true Return type: PROMISE - name: members | type: array | description: New members. - name: memberId | type: string | description: Member GUID. See the Members API for more details. - name: role | type: GroupRole | description: Group member role. - name: value | type: Role | description: Member's role. - enum: - MEMBER: Regular group member. - ADMIN: Group administrator. - name: joinedDate | type: Date | description: Date and time the group Member joined the group. ``` ### Examples ### Add site members to a group (with elevated permissions) ```javascript import { members } from '@wix/groups'; import { auth } from '@wix/essentials'; const elevatedAddGroupMembers = auth.elevate(members.addGroupMembers); // Sample groupId value: '0261a737-2361-4468-a3b1-5ec2b0667836' // // Sample memberIds value: ['937cd3db-e9be-4980-93c1-a6d767a11050', '7fe8e9e1-d050-4c86-9684-e7f231600a34'] async function addGroupMembers(groupId, memberIds) { try { const result = await elevatedAddGroupMembers(groupId, memberIds); return result; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * members: [ * { * "joinedDate": "Sun Aug 01 2021 12:32:35 GMT+0300" * "memberId": "437cd3db-e9be-4980-93c1-a6d767a11050" * "role": {"value": "ADMIN"} * }, * { * "joinedDate": "Tues Jun 30 2019 10:09:33 GMT+0300" * "memberId": "7fe8e9e1-d050-4c86-9684-e7f231600a34" * "role": {"value": "MEMBER"} * } * ] */ ``` ### Add site members to a group ```javascript import { members } from '@wix/groups'; // Sample groupId value: '0261a737-2361-4468-a3b1-5ec2b0667836' // // Sample memberIds value: ['937cd3db-e9be-4980-93c1-a6d767a11050', '7fe8e9e1-d050-4c86-9684-e7f231600a34'] async function addGroupMembers(groupId, memberIds) { try { const result = await members.addGroupMembers(groupId, memberIds); return result; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * members: [ * { * "joinedDate": "Sun Aug 01 2021 12:32:35 GMT+0300" * "memberId": "437cd3db-e9be-4980-93c1-a6d767a11050" * "role": {"value": "ADMIN"} * }, * { * "joinedDate": "Tues Jun 30 2019 10:09:33 GMT+0300" * "memberId": "7fe8e9e1-d050-4c86-9684-e7f231600a34" * "role": {"value": "MEMBER"} * } * ] */ ``` ### addGroupMembers (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { members } from '@wix/groups'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { members }, // Include the auth strategy and host as relevant }); async function addGroupMembers(groupId,memberIds) { const response = await myWixClient.members.addGroupMembers(groupId,memberIds); }; ``` ---