In-app Chat
SDK Error Codes
On this page

Community Member Management

2026-06-24

Feature Overview

ZIM SDK provides comprehensive Community member management capabilities, supporting the following features:

  • Invite users to join a Community
  • Remove Community members
  • Update member roles
  • Transfer Community ownership
  • Query Community member list
  • Query specified member information
  • Set member mute status
  • Listen for member state and information changes

Prerequisites

  • Please refer to Implement basic message sending and receiving to complete ZIM SDK acquisition, initialization, and user login.
  • Please refer to Authenticate with Token to implement user authentication and login.
  • Community features require ZIM SDK 3.0.0 or later.
  • Community is a premium feature. Please contact ZEGOCLOUD Technical Support for activation before use.
  • The Token generation method for Community features is the same as for other ZIM features, with no additional permission declarations required.

Invite Users to Join a Community

Call the inviteUsersIntoCommunity API to batch invite users to join a Community. The invitation does not require the other party's consent; invited users directly become Community members. Invited users must already be registered in the system. A single API call can invite up to 100 users to join a Community.

Failed user information will be returned through errorUserList.

import im.zego.zim.ZIM;
import im.zego.zim.callback.ZIMCommunityUsersInvitedCallback;
import im.zego.zim.entity.ZIMError;
import im.zego.zim.entity.ZIMErrorUserInfo;
import im.zego.zim.enums.ZIMErrorCode;

ArrayList<String> userIDs = new ArrayList<>();
userIDs.add("user_1");
userIDs.add("user_2");

zim.inviteUsersIntoCommunity(userIDs, communityID, new ZIMCommunityUsersInvitedCallback() {
    @Override
    public void onCommunityUsersInvited(String communityID, ArrayList<ZIMErrorUserInfo> errorUserList, ZIMError errorInfo) {
        if (errorInfo.code == ZIMErrorCode.SUCCESS) {
            // Invitation complete; errorUserList lists users for whom the invitation failed
        }
    }
});
Error CodeDescriptionRecommended Action
6001004Community does not existConfirm if the communityID is correct
6001005User is not in the CommunityOnly occurs in specific scenarios; confirm user status
6001007Community permission errorConfirm whether the current user has invitation permission

Remove Community Members

Call the kickCommunityMembers API to batch remove specified members from the Community. A single API call can remove up to 100 users from the Community.

Warning

Only the Community owner and admins can call this API.

ArrayList<String> userIDs = new ArrayList<>();
userIDs.add("user_1");
userIDs.add("user_2");

zim.kickCommunityMembers(userIDs, communityID, new ZIMCommunityMembersKickedCallback() {
    @Override
    public void onCommunityMembersKicked(String communityID, ArrayList<ZIMErrorUserInfo> errorUserList, ZIMError errorInfo) {
        if (errorInfo.code == ZIMErrorCode.SUCCESS) {
            // Removal complete; errorUserList lists users for whom the operation failed
        }
    }
});

Update Community Member Role

Call the updateCommunityMemberRole API to modify a specified member's role in the Community, such as setting a regular member as an admin.

Warning

Only the Community owner can call this API. Community roles: 1 for Community owner, 2 for Community admin, 3 for Community regular member.

//ZIMCommunityMemberRole.OWNER = Community owner, ZIMCommunityMemberRole.ADMIN = Community admin, ZIMCommunityMemberRole.MEMBER = Community regular member
zim.updateCommunityMemberRole(ZIMCommunityMemberRole.ADMIN, "target_user_id", communityID,
    new ZIMCommunityMemberRoleUpdatedCallback() {
        @Override
        public void onCommunityMemberRoleUpdated(String communityID, String forUserID, ZIMCommunityMemberRole memberRole, ZIMError errorInfo) {
            if (errorInfo.code == ZIMErrorCode.SUCCESS) {
                // Role updated successfully
            }
        }
    });

Transfer Community Ownership

Call the transferCommunityOwner API to transfer the ownership of the current Community to another member within the Community. After the transfer, the original owner will become a regular member.

Warning

Only the Community owner can call this API.

zim.transferCommunityOwner("new_owner_user_id", communityID,
    new ZIMCommunityOwnerTransferredCallback() {
        @Override
        public void onCommunityOwnerTransferred(String communityID, String toUserID, ZIMError errorInfo) {
            if (errorInfo.code == ZIMErrorCode.SUCCESS) {
                // Transferred successfully
            }
        }
    });

Query Community Member List

Call the queryCommunityMemberList API to retrieve the member list of a specified Community in pages.

Pagination rules are the same as querying the Community list: for the first query, set config.nextFlag to 0, then pass the returned nextFlag to the next request until nextFlag returns 0.

ZIMCommunityMemberListQueryConfig config = new ZIMCommunityMemberListQueryConfig();
config.setNextFlag(0);  // Set to 0 for the first query

zim.queryCommunityMemberList(communityID, 100, config, new ZIMCommunityMemberListQueriedCallback() {
    @Override
    public void onCommunityMemberListQueried(String communityID, ArrayList<ZIMCommunityMemberInfo> memberList, long nextFlag, ZIMError errorInfo) {
        if (errorInfo.code == ZIMErrorCode.SUCCESS) {
            // memberList is the member list for the current page
        }
    }
});

Query Specified Member Information

Call the queryCommunityMembers API to batch query specified users' member information in the Community, including role, mute status, etc.

ArrayList<String> userIDs = new ArrayList<>();
userIDs.add("user_1");
userIDs.add("user_2");

zim.queryCommunityMembers(userIDs, communityID, new ZIMCommunityMembersQueriedCallback() {
    @Override
    public void onCommunityMembersQueried(String communityID, ArrayList<ZIMCommunityMemberInfo> memberList, ArrayList<ZIMErrorUserInfo> errorUserList, ZIMError errorInfo) {
        if (errorInfo.code == ZIMErrorCode.SUCCESS) {
            // memberList contains the queried member information
        }
    }
});

Mute Members

Call the muteCommunityMembers API to batch set the mute status of specified members in specified Channels within the Community. Mute configuration is passed through ZIMCommunityMemberMuteConfig.

Configuration FieldDescription
channelIDSpecifies the Channel ID where the mute takes effect. Leave blank to apply to all Channels.
durationMute duration (seconds), range 1-2592001 (approximately 30 days), or -1 for permanent mute.
Warning

Only the Community owner and admins can call this API.

ArrayList<String> userIDs = new ArrayList<>();
userIDs.add("user_1");
userIDs.add("user_2");

ZIMCommunityMemberMuteConfig config = new ZIMCommunityMemberMuteConfig();
config.setDuration(3600);        // Mute for 1 hour; -1 for permanent mute
config.setChannelID("channel_001");  // Specify a Channel; leave blank to apply to all Channels

// isMute = true to mute, false to unmute
zim.muteCommunityMembers(true, userIDs, communityID, config,
    new ZIMCommunityMembersMutedCallback() {
        @Override
        public void onCommunityMembersMuted(String communityID, String channelID, boolean isMute, ArrayList<ZIMErrorUserInfo> errorUserList, ZIMError errorInfo) {
            if (errorInfo.code == ZIMErrorCode.SUCCESS) {
                // Mute set successfully
            }
        }
    });

Listen for Member Changes

Member State Changes

When members join or leave a Community, the SDK will trigger the onCommunityMemberStateChanged callback. Use updateInfo.getState() to determine whether a member has entered (ENTERED) or exited (EXITED).

zim.setEventHandler(new ZIMEventHandler() {
    @Override
    public void onCommunityMemberStateChanged(ZIM zim, ZIMCommunityMemberStateChangedEventResult result) {
        for (ZIMCommunityMemberStateChangeInfo updateInfo : result.getUpdateInfoList()) {
            if (updateInfo.getState() == ZIMCommunityMemberChangeState.ENTERED) {
                // Member joined the Community
            } else if (updateInfo.getState() == ZIMCommunityMemberChangeState.EXITED) {
                // Member left the Community
            }
        }
    }
});

Member Information Updates

When a Community member's nickname, role, mute status, or other information changes, the SDK will trigger the onCommunityMemberInfoUpdated callback.

zim.setEventHandler(new ZIMEventHandler() {
    @Override
    public void onCommunityMemberInfoUpdated(ZIM zim, ZIMCommunityMemberInfoUpdatedEventResult result) {
        for (ZIMCommunityMemberInfoUpdateInfo updateInfo : result.getUpdateInfoList()) {
            ZIMCommunityMemberInfo memberInfo = updateInfo.getMemberInfo();
            // memberInfo.memberRole: member role
            // memberInfo.muteInfo: mute information
            // memberInfo.enterInfo: member join information
        }
    }
});

Previous

Community management

Next

Channel management