Skip to main content

Manage group roles

Last updated on December 18, 2024

Overview

This article guides you through integrating the AccelByte Gaming Services (AGS) Group service into your game client to enable the following functionalities:

  • Retrieving group roles
  • Allowing group admins to assign and remove member roles
How-to Guide

Group roles are created in the AGS Admin Portal. For more information, refer to the how-to guide for configuring groups.

Retrieve group roles

To enable your game client to retrieve group roles that exist in your namespace, use this code:

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();

FAccelByteModelsLimitOffsetRequest RequestContent = {};
RequestContent.Limit = 100;
RequestContent.Offset = 0;

ApiClient->Group.GetMemberRoles(RequestContent, THandler<FAccelByteModelsGetMemberRolesListResponse>::CreateLambda([](const FAccelByteModelsGetMemberRolesListResponse& Result)
{
// Do something if GetMemberRoles succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetMemberRoles fails
}));

Assign group roles

To enable group admins to assign roles to members, use this code:

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();

FString MemberRoleId = "YourMemberRoleId";

FAccelByteModelsUserIdWrapper RequestContent = {};
RequestContent.UserId = "YourUserId";

ApiClient->Group.AssignMemberRole(MemberRoleId, RequestContent, THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateLambda([](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if AssignMemberRole succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if AssignMemberRole fails
}));

Remove a member's role

To enable group admins to remove a member's role, use this code:

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();

FString MemberRoleId = "YourMemberRoleId";

FAccelByteModelsUserIdWrapper RequestContent = {};
RequestContent.UserId = "YourUserId";

ApiClient->Group.DeleteMemberRole(MemberRoleId, RequestContent, FVoidHandler::CreateLambda([]()
{
// Do something if DeleteMemberRole succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if DeleteMemberRole fails
}));