Browse SDKs · WASM
SDKsWASM

Transfer group ownership

Transfer ownership of a group to another member.

Copy

Only the current group owner can call transferGroupOwner(). groupID is the ID of the target group, and newOwnerUserID is the new owner's user ID. The target user must be an active member of the group.

await openimsdk.transferGroupOwner({
  groupID,
  newOwnerUserID: targetUserID,
});

State changes after the call

When the Promise resolves, OpenIMServer has completed the ownership transfer: the previous owner becomes a regular member, and the new owner receives the owner role. Role changes are reported through OnGroupMemberInfoChanged, whose data is a single GroupMemberItem. A transfer can update both the previous and new owner's member records; use groupID:userID to find and update each matching member.

For the complete listener and cleanup implementation, see List group members. Do not infer the transfer result from the number of events alone. When you need the current owner and administrators, call getGroupMemberOwnerAndAdmin(groupID). After a new login or reconnection, query the current members and their roles first, then merge later changes from member events into the list.

If the group owner needs to leave the group, transfer ownership before calling quitGroup(). If the group is no longer needed, the owner can instead call dismissGroup(), but dismissing the group affects every member and is not a substitute for an ordinary ownership transfer.