How to restrict a user join a signle group (clan)?

Currently, the player can send multiple join group requests, and the admins in different groups can accept the requests. finally, the player will join to all the groups that he requests.

any way can only allow first request acceptance? and if one request is accepted then all other requests will be removed or invalid?

Hello @mengxin,

You can register a before-hook on JoinGroups to validate if the user already has any pending join requests and reject more requests.

Best.

Let me explain the details of the general clan feature.

  1. Assume there are three private clans: Clan1, Clan2, and Clan3.
  2. UserA tries to join these clans and sends requests (API: client.JoinGroupAsync(session, groupId)).
  3. Now, there are three join requests for the three clans.
  4. Suppose the admin of Clan2 accepts the request; then the player will join Clan2 (API: client.AddGroupUsersAsync(session, groupId, userIds)).
  5. After Clan2 accepts the request, we want to remove the other two requests, meaning the admins of Clan1 and Clan3 cannot see the requests (at least at the database level).
  6. Even if the admins of Clan1 and Clan3 see the requests in cache, when they try to accept them, they should receive an error indicating that the player has already joined another clan or that the request does not exist.

is it possible to achieve 5 and 6?

If multiple requests can be sent, then I’d instead register a before-hook to AddGroupUsersAsync that prevents the add to go through if the user has already been accepted to a group.

I’d also add an after-hook to AddGroupUsersAsync that lists all the groups the user has requested to join and then use the runtime LeaveGroup function to remove those requests.