Skip to main content
Quick Reference for AI Agents & Developers
// Change member scope (admin only)
CometChat.updateGroupMemberScope(
    "UID", 
    "GUID", 
    CometChatConstants.SCOPE_MODERATOR,
    object : CallbackListener<String>() {
        override fun onSuccess(message: String) { }
        override fun onError(e: CometChatException) { }
    })
Available Scopes:
  • SCOPE_ADMIN - Full control over group
  • SCOPE_MODERATOR - Can moderate members and content
  • SCOPE_PARTICIPANT - Regular member (default)
Note: Only group admins can change member scopes.
Available via: SDK | REST API | UI Kits

Change Scope of a Group Member

To change the scope of a group member, use the changeGroupMemberScope() method.
private String GUID = "GUID";
private String UID = "UID";
private String scope = CometChatConstants.SCOPE_ADMIN;

CometChat.updateGroupMemberScope(UID, GUID, scope, new CometChat.CallbackListener<String>() {
  @Override
  public void onSuccess(String successMessage) {
    Log.d(TAG, "User scope updated successfully");
  }

  @Override
  public void onError(CometChatException e) {
    Log.d(TAG, "User scope update failed with exception: " + e.getMessage());
  }
});
This method takes the below parameters:
ParameterDescription
UIDThe UID of the member whose scope you would like to change
GUIDThe GUID of the group for which the member’s scope needs to be changed
scopethe 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.

Real-Time Group Member Scope Changed Events

How do I know when someone’s scope is changed while my app is running? To receive real-time events whenever a group member’s scope changes, override the onGroupMemberScopeChanged() method of the GroupListener class.
CometChat.addGroupListener(YourActivity.class.getSimpleName(), new CometChat.GroupListener() {
  @Override
  public void onGroupMemberScopeChanged(Action action, User updatedBy, User updatedUser, String scopeChangedTo, String scopeChangedFrom, Group group) {

  }
});

Missed Group Member Scope Changed Events

How do I know when someone’s scope is changed while 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 an Action message. An Action message is a sub-class of the BaseMessage class. For the group member scope changed event, in the Action object received, the following fields can help you get the relevant information-
  1. action - scopeChanged
  2. actionOn - User object containing the details of the user whos scope has been changed
  3. actionBy - User object containing the details of the user who changed the scope of the member
  4. actionFor - Group object containing the details of the group in which the member scope was changed
  5. oldScope - The original scope of the member
  6. 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.

Best Practices

Keep the number of admins small (2-3) to maintain clear ownership and control. Too many admins can lead to conflicts and management issues.
Use the moderator role for trusted members who help manage the group without full admin privileges. This provides a middle tier of authority.
Prompt admins to confirm before changing member scopes, especially when promoting to admin or demoting from admin/moderator roles.
Listen for scope change events to maintain an audit log of permission changes for security and accountability.

Troubleshooting

Symptom: updateGroupMemberScope() fails with “Insufficient permissions” error.Cause: User is not an admin of the group.Solution: Only group admins can change member scopes. Moderators cannot change scopes. Check the user’s scope before showing this option.
Symptom: Admin cannot change their own scope.Cause: Admins cannot demote themselves to prevent accidental loss of admin access.Solution: Have another admin change your scope, or use transfer-group-ownership if you want to step down.
Symptom: Scope change fails with “Invalid scope” error.Cause: Scope value is not one of the valid constants.Solution: Use only CometChatConstants.SCOPE_ADMIN, SCOPE_MODERATOR, or SCOPE_PARTICIPANT.

Next Steps