Quick Reference for AI Agents & DevelopersAvailable Scopes:
SCOPE_ADMIN- Full control over groupSCOPE_MODERATOR- Can moderate members and contentSCOPE_PARTICIPANT- Regular member (default)
Change Scope of a Group Member
To change the scope of a group member, use thechangeGroupMemberScope() method.
- Java
- Kotlin
| 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.CometChatConstants.SCOPE_ADMIN (admin) 2.CometChatConstants.SCOPE_MODERATOR (moderator) 3.CometChatConstants.SCOPE_PARTICIPANT (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
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 theonGroupMemberScopeChanged() method of the GroupListener class.
- Java
- Kotlin
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 anAction 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-
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
Limit Admin Count
Limit Admin Count
Keep the number of admins small (2-3) to maintain clear ownership and control. Too many admins can lead to conflicts and management issues.
Promote Trusted Members to Moderator
Promote Trusted Members to Moderator
Use the moderator role for trusted members who help manage the group without full admin privileges. This provides a middle tier of authority.
Confirm Before Scope Changes
Confirm Before Scope Changes
Prompt admins to confirm before changing member scopes, especially when promoting to admin or demoting from admin/moderator roles.
Track Scope Changes
Track Scope Changes
Listen for scope change events to maintain an audit log of permission changes for security and accountability.
Troubleshooting
Scope Change Failed - Insufficient Permissions
Scope Change Failed - Insufficient Permissions
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.Cannot Change Own Scope
Cannot Change Own Scope
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.
Invalid Scope Value
Invalid Scope Value
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.