In-app Chat
SDK Error Codes
On this page

Community Member Management

2026-07-06

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.

std::vector<std::string> userIDs = {"user_1", "user_2"};

zim_->inviteUsersIntoCommunity(userIDs, communityID,
    [=](const std::string &communityID,
        const std::vector<zim::ZIMErrorUserInfo> &errorUserList,
        const zim::ZIMError &errorInfo) {
        if (errorInfo.code == zim::ZIM_ERROR_CODE_SUCCESS) {
            // Invitation complete
        }
    });
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.

std::vector<std::string> userIDs = {"user_1", "user_2"};

zim_->kickCommunityMembers(userIDs, communityID,
    [=](const std::string &communityID,
        const std::vector<zim::ZIMErrorUserInfo> &errorUserList,
        const zim::ZIMError &errorInfo) {
        if (errorInfo.code == zim::ZIM_ERROR_CODE_SUCCESS) {
            // Removal complete
        }
    });

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.

// ZIM_COMMUNITY_MEMBER_ROLE_ADMIN = Admin
zim_->updateCommunityMemberRole(zim::ZIM_COMMUNITY_MEMBER_ROLE_ADMIN,
                                 "target_user_id", communityID,
    [=](const std::string &communityID,
        const std::string &forUserID,
        zim::ZIMCommunityMemberRole memberRole,
        const zim::ZIMError &errorInfo) {
        if (errorInfo.code == zim::ZIM_ERROR_CODE_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,
    [=](const std::string &communityID,
        const std::string &toUserID,
        const zim::ZIMError &errorInfo) {
        if (errorInfo.code == zim::ZIM_ERROR_CODE_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.

zim::ZIMCommunityMemberListQueryConfig config;
config.nextFlag = 0;

zim_->queryCommunityMemberList(communityID, 100, config,
    [=](const std::string &communityID,
        const std::vector<zim::ZIMCommunityMemberInfo> &memberList,
        long long nextFlag,
        const zim::ZIMError &errorInfo) {
        if (errorInfo.code == zim::ZIM_ERROR_CODE_SUCCESS) {
            // Queried successfully
        }
    });

Query Specified Member Information

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

std::vector<std::string> userIDs = {"user_1", "user_2"};

zim_->queryCommunityMembers(userIDs, communityID,
    [=](const std::string &communityID,
        const std::vector<zim::ZIMCommunityMemberInfo> &memberList,
        const std::vector<zim::ZIMErrorUserInfo> &errorUserList,
        const zim::ZIMError &errorInfo) {
        if (errorInfo.code == zim::ZIM_ERROR_CODE_SUCCESS) {
            // Queried successfully
        }
    });

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.

std::vector<std::string> userIDs = {"user_1", "user_2"};

zim::ZIMCommunityMemberMuteConfig config;
config.duration = 3600;
config.channelID = "channel_001";

zim_->muteCommunityMembers(true, userIDs, communityID, config,
    [=](const std::string &communityID,
        bool isMute,
        const std::vector<std::string> &mutedUserIDs,
        const zim::ZIMError &errorInfo) {
        if (errorInfo.code == zim::ZIM_ERROR_CODE_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).

void onCommunityMemberStateChanged(zim::ZIM *zim,
    const zim::ZIMCommunityMemberStateChangedEventResult &result) override {
    for (const auto &updateInfo : result.updateInfoList) {
        if (updateInfo.state == zim::ZIM_COMMUNITY_MEMBER_CHANGE_STATE_ENTERED) {
            // Member joined the Community
        } else if (updateInfo.state == zim::ZIM_COMMUNITY_MEMBER_CHANGE_STATE_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.

void onCommunityMemberInfoUpdated(zim::ZIM *zim,
    const zim::ZIMCommunityMemberInfoUpdatedEventResult &result) override {
    for (const auto &updateInfo : result.updateInfoList) {
        // updateInfo.memberInfo contains the updated member information
    }
}
2026-06-24

Previous

Community management

Next

Channel management