Quick Reference
Change Scope of a Group Member
In order to change the scope of a group member, you can use thechangeGroupMemberScope().
- JavaScript
- TypeScript
| Parameter | Description |
|---|---|
UID | The UID of the member whose scope you would like to change |
GUID | The GUID of the group for which the member’s scope needs to be changed |
scope | The updated scope of the member. This can be either of the 3 values: 1.CometChat.SCOPE.ADMIN2.CometChat.SCOPE.MODERATOR 3.CometChat.SCOPE.PARTICIPANT |
participant. Only the Admin of the group can change the scope of any participant in the group.
Real-Time Group Member Scope Changed Events
In other words, as a member of a group, how do I know when someone’s scope is changed when my app is running? In order to receive real-time events for the change member scope event, you will need to override theonGroupMemberScopeChanged() method of the GroupListener class
- JavaScript
- TypeScript
Missed Group Member Scope Changed Events
In other words, as a member of a group, how do I know when someone’s scope is changed when my app is not running? When you retrieve the list of previous messages if a member’s scope has been changed for any group that the logged-in user is a member of, the list of messages will contain anAction message. An Action message is a sub-class of BaseMessage class.
For the group member scope changed event, in the Action object received, the following fields can help you get the relevant information-
action-scopeChangedactionOn- User object containing the details of the user whos scope has been changedactionBy- User object containing the details of the user who changed the scope of the memberactionFor- Group object containing the details of the group in which the member scope was changedoldScope- The original scope of the membernewScope- The updated scope of the member
Best Practices
Best Practices
- Only admins can change member scope — validate roles before calling
updateGroupMemberScope() - Update your local group member list after a successful scope change to keep the UI in sync
- Handle the
onGroupMemberScopeChangedlistener to reflect scope changes made by other admins in real time - Consider showing a confirmation dialog before promoting a member to admin, as this grants full group control
Troubleshooting
Troubleshooting
- ERR_NOT_A_MEMBER: The logged-in user is not a member of the group. Ensure the user has joined the group first.
- ERR_INSUFFICIENT_PERMISSIONS: Only group admins can change member scope. Verify the logged-in user’s role.
- Scope change not reflecting: Make sure you’ve registered a
GroupListenerand are handlingonGroupMemberScopeChanged. - Missed events not appearing: Fetch previous messages using
MessagesRequest— scope change actions appear asActionmessages in the message history.