> For the complete documentation index, see [llms.txt](https://bayun.gitbook.io/bayuncoresdk-cpp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bayun.gitbook.io/bayuncoresdk-cpp/groups/remove-group-members-except-list.md).

# 6.10 Remove Group Members Except List

The `removeGroupMembersExceptList` function is used to remove all members of the Group except the list of group members. Calling member is not removed from the group. Any existing member of the group can remove other members. The developer can choose to build stricter access-control mechanisms on top of this if desired (e.g. only the group-owner or group-admin is authorized to remove members from the group).

The function takes the following parameters :

* **sessionId** : Unique SessionId which is received in the registration/login function response.
* **groupId**  :  GroupId of the group.
* **groupMembers** : List of members **NOT** to be removed from the group. If the list is empty, all the members of the group are  removed except the calling member.
* **removeCallingMember :** Determines whether the calling member should be removed from the group or not.

{% tabs %}
{% tab title="C++" %}

```cpp
#include "BayunCore.h"

std::vector<Bayun::GroupMember> groupMembers;
Bayun::GroupMember groupMember1("<companyEmployeeId>", "<companyName>");
Bayun::GroupMember groupMember2("<companyEmployeeId>", "<companyName>");
groupMembers.push_back(groupMember1);
groupMembers.push_back(groupMember2);

bool removeCallingMember = false;
Bayun::ShAddGroupMemberResponse response = bayunCore->removeGroupMembersExceptList("<sessionId>",
 groupId, groupMembers, removeCallingMember);
```

{% endtab %}
{% endtabs %}
