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.CometChatConstants.SCOPE_ADMIN (admin) 2.CometChatConstants.SCOPE_MODERATOR (moderator) 3.CometChatConstants.SCOPE_PARTICIPANT (participant)
The default scope of any member is participant. Only the Admin of the group can change the scope of any participant in the group.
When a member’s scope changes, group members receive a real-time event in onGroupMemberScopeChanged() of the GroupListener class. The callback provides an Action object, the updating User, the updated User, and the Group.
Java
Kotlin
CometChat.addGroupListener(YourActivity.class.getSimpleName(), new CometChat.GroupListener() { @Override public void onGroupMemberScopeChanged(Action action, User updatedBy, User updatedUser, String scopeChangedTo, String scopeChangedFrom, Group group) { }});
When fetching message history, scope changes appear as Action messages with these fields:
action - scopeChanged
actionOn - User object containing the details of the user whos scope has been changed
actionBy - User object containing the details of the user who changed the scope of the member
actionFor - Group object containing the details of the group in which the member scope was changed
oldScope - The original scope of the member
newScope - The updated scope of the member
Always remove group listeners when they’re no longer needed (e.g., in onDestroy() or when navigating away). Failing to remove listeners can cause memory leaks and duplicate event handling.