Report misbehaving users
Requires App Context
Enable App Context in the Admin Portal to work with user metadata.
Administrators are chat users with SDK instances initialized with a Secret Key. Admin moderation capabilities:
- Mute users on channels
- Ban users from accessing channels
Use Access Manager to enforce restrictions.
Asynchronous and synchronous method execution
Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.
-
Asynchronous methods (
Asyncsuffix) returnvoidand take an optional delegate parameter that fires when the operation completes.1Channel->SetRestrictionsAsync(UserID, Ban, Mute, OnOperationResponseDelegate, Reason);You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the
Nativesuffix (for example,FOnPubnubChatOperationResponseNative). -
Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly.
1FPubnubChatOperationResult Result = Channel->SetRestrictions(UserID, Ban, Mute, Reason);
Mute or ban users
Mute or ban users with SetRestrictions() on the Chat, User, or Channel object. All three produce the same output with different input parameters.
How it works:
- Muting/banning creates a
moderationevent (mutedorbanned) - A moderation membership is created with
PUBNUB_INTERNAL_MODERATION_prefix (secured via Access Manager, filtered fromGetMemberships()results) - Lifting restrictions removes the moderation membership and creates a
liftedevent
Listen to moderation events to trigger actions like removing memberships. Check restrictions to verify user status.
Secret Key required
Initialize with Secret Key (from Admin Portal) for admin operations. Never expose Secret Key to clients. If compromised, generate a new one in the Admin Portal.
Method signature
- C++ / Input parameters
- Blueprint
-
User->SetRestrictions()1User->SetRestrictions(
2 const FString ChannelID,
3 bool Ban,
4 bool Mute,
5 FString Reason = ""
6); -
Channel->SetRestrictions()1Channel->SetRestrictions(
2 const FString UserID,
3 bool Ban,
4 bool Mute,
5 FString Reason = ""
6); -
Chat->SetRestrictions()1Chat->SetRestrictions(FPubnubChatRestriction Restriction);
Restriction#- Struct containing
UserID,ChannelID,Ban,Mute, andReasonfields. Used byChatonly.- Required for Chat
- Yes
- Required for User
- No
- Required for Channel
- No
ChannelID#- ID of the channel on/from which the user should be muted or banned. Used by
UserandChannel.- Required for Chat
- No
- Required for User
- Yes
- Required for Channel
- No
UserID#- Unique User ID of the user to mute or ban. Used by
Channelonly.- Required for Chat
- No
- Required for User
- No
- Required for Channel
- Yes
Ban#- Set to
trueto ban the user from the channel or tofalseto unban them.- Required for Chat
- No
- Required for User
- Yes
- Required for Channel
- Yes
Mute#- Set to
trueto mute the user on the channel or tofalseto unmute them.- Required for Chat
- No
- Required for User
- Yes
- Required for Channel
- Yes
Reason#- Reason why you want to ban or mute the user.
- Required for Chat
- No
- Required for User
- No
- Required for Channel
- No
Output
| Method | Return type |
|---|---|
User->SetRestrictions() | FPubnubChatOperationResult |
Chat->SetRestrictions() | FPubnubChatOperationResult |
Channel->SetRestrictions() | FPubnubChatOperationResult |
Sample code
Mute
Mute support_agent_15 on the support channel.
-
SetRestrictions()(on theChatobject)- C++
1UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|Chat|Moderation")
2void SetRestrictionsSample();
3
4UFUNCTION()
5void OnSetRestrictionsResponse(const FPubnubChatOperationResult& Result);
6
show all 26 lines1
2// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
3void ASample_Chat::SetRestrictionsSample()
4{
5
6 // Assumes Chat is a valid and initialized instance of UPubnubChat
7
8 // Set or lift moderation restrictions (e.g. ban or mute a user on a channel)
9 FPubnubChatRestriction Restriction;
10 Restriction.UserID = TEXT("Player_002");
11 Restriction.ChannelID = TEXT("Lobby_001");
12 Restriction.Ban = true;
13 Restriction.Reason = TEXT("Violation of rules");
14
15 FOnPubnubChatOperationResponseNative Callback; -
SetRestrictions()(on theUserobject)- C++
- Blueprint
1
2// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
3void ASample_ChatUser::SetRestrictionsSample()
4{
5
6 // Assumes User is a valid UPubnubChatUser (e.g. from GetUser)
7
8 // Channel ID on which to set or lift restrictions for this user
9 FString ChannelID = TEXT("lobby-01");
10
11 // Set or lift ban/mute for this user on the channel
12 User->SetRestrictionsAsync(ChannelID, false, true, nullptr, "inappropriate language");
13} -
SetRestrictions()(on theChannelobject)- C++
- Blueprint
1
2// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
3void ASample_ChatChannel::SetRestrictionsSample()
4{
5
6 // Assumes Channel is a valid UPubnubChatChannel (e.g. from GetChannel)
7
8 // User ID to set restrictions for
9 FString UserID = TEXT("user-abc123");
10
11 // Set restriction (ban in this example)
12 Channel->SetRestrictionsAsync(UserID, true, false, nullptr, TEXT("Cheater"));
13}
Ban
Ban support_agent_15 from the support channel.
-
SetRestrictions()(on theChatobject)- C++
1UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|Chat|Moderation")
2void SetRestrictionsSample();
3
4UFUNCTION()
5void OnSetRestrictionsResponse(const FPubnubChatOperationResult& Result);
6
show all 26 lines1
2// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
3void ASample_Chat::SetRestrictionsSample()
4{
5
6 // Assumes Chat is a valid and initialized instance of UPubnubChat
7
8 // Set or lift moderation restrictions (e.g. ban or mute a user on a channel)
9 FPubnubChatRestriction Restriction;
10 Restriction.UserID = TEXT("Player_002");
11 Restriction.ChannelID = TEXT("Lobby_001");
12 Restriction.Ban = true;
13 Restriction.Reason = TEXT("Violation of rules");
14
15 FOnPubnubChatOperationResponseNative Callback; -
SetRestrictions()(on theUserobject — ban example)1User->SetRestrictionsAsync("support", true, false, nullptr, "Banned for sending pictures of pineapple pizza."); -
SetRestrictions()(on theChannelobject)- C++
- Blueprint
1
2// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
3void ASample_ChatChannel::SetRestrictionsSample()
4{
5
6 // Assumes Channel is a valid UPubnubChatChannel (e.g. from GetChannel)
7
8 // User ID to set restrictions for
9 FString UserID = TEXT("user-abc123");
10
11 // Set restriction (ban in this example)
12 Channel->SetRestrictionsAsync(UserID, true, false, nullptr, TEXT("Cheater"));
13}
Lift restrictions
Check restrictions
One user on one channel
Check mute or ban restrictions for a user on a specific channel with GetChannelRestrictions() or GetUserRestrictions().
Method signature
- C++ / Input parameters
- Blueprint
-
User->GetChannelRestrictions()1User->GetChannelRestrictions(UPubnubChatChannel* Channel) -
Channel->GetUserRestrictions()1Channel->GetUserRestrictions(UPubnubChatUser* User);
Output
User->GetChannelRestrictions()#- Returned object containing
ResultandRestriction. Channel->GetUserRestrictions()#- Returned object containing
ResultandRestriction. - property of Channel->GetUserRestrictions():
Result# - Operation status.
- property of Channel->GetUserRestrictions():
Restriction# - Restriction details.
- property of Restriction:
UserID# - ID of the restricted user.
- property of Restriction:
ChannelID# - ID of the channel.
- property of Restriction:
Ban# - Info whether the user is banned from the channel.
- property of Restriction:
Mute# - Info whether the user is muted on the channel.
- property of Restriction:
Reason# - Reason why the user was banned or muted.
Sample code
Check if the user support_agent_15 has any restrictions set on the support channel.
-
GetChannelRestrictions()- C++
- Blueprint
show all 23 lines1
2// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
3void ASample_ChatUser::GetChannelRestrictionsSample()
4{
5
6 // Assumes User is a valid UPubnubChatUser (e.g. from GetUser)
7
8 // Channel to query restrictions for
9 UPubnubChatChannel* Channel = nullptr;
10
11 // Callback for when the operation completes (returns ban/mute/reason)
12 FOnPubnubChatGetRestrictionResponseNative Callback;
13 // ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
14 Callback.BindUObject(this, &ASample_ChatUser::OnGetChannelRestrictionsResponse);
15 User->GetChannelRestrictionsAsync(Channel, Callback); -
GetUserRestrictions()- C++
- Blueprint
show all 23 lines1
2// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
3void ASample_ChatChannel::GetUserRestrictionsSample()
4{
5
6 // Assumes Channel is a valid UPubnubChatChannel (e.g. from GetChannel)
7
8 // User to query restrictions for (e.g. from GetUser or members list)
9 UPubnubChatUser* User = nullptr;
10
11 // Callback for when the operation completes (returns ban/mute/reason for this user)
12 FOnPubnubChatGetRestrictionResponseNative Callback;
13 // ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
14 Callback.BindUObject(this, &ASample_ChatChannel::OnGetUserRestrictionsResponse);
15 Channel->GetUserRestrictionsAsync(User, Callback);
One user on all channels
Check mute or ban restrictions for a user across all their channels with GetChannelsRestrictions().
Method signature
1User->GetChannelsRestrictions(
2 int Limit = 0,
3 FPubnubMembershipSort Sort = FPubnubMembershipSort(),
4 FPubnubPage Page = FPubnubPage()
5);
Limit#- Number of objects to return in response. The default (and maximum) value is
100. Page#- Object used for pagination to define which previous or next result page you want to fetch.
- property of Page:
Next# - Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
- property of Page:
Prev# - Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
nextparameter is supplied. Sort#- Struct used to specify a property to sort by and sort direction. Available options are
id,name, andupdated. Useascordescto specify the sorting direction. By default, the items are sorted by the last updated date.
Output
FPubnubChatGetRestrictionsResult#- Returned object containing these fields:
Result,Restrictions,Page, andTotal. - property of FPubnubChatGetRestrictionsResult:
Result# - Operation status.
- property of FPubnubChatGetRestrictionsResult:
Restrictions# - Array containing restrictions.
- property of Restrictions:
UserID# - ID of the restricted user.
- property of Restrictions:
ChannelID# - ID of the channel containing user restrictions.
- property of Restrictions:
Ban# - Info whether the user is banned from the given channel.
- property of Restrictions:
Mute# - Info whether the user is muted on the given channel.
- property of Restrictions:
Reason# - Reason why the user was banned or muted.
- property of FPubnubChatGetRestrictionsResult:
Page# - Object used for pagination to define which previous or next result page you want to fetch.
- property of Page:
Next# - Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
- property of Page:
Prev# - Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
Nextparameter is supplied. - property of FPubnubChatGetRestrictionsResult:
Total# - Total number of restrictions.
Sample code
List all mute and ban restrictions set for a user.
1
2// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
3void ASample_ChatUser::GetChannelsRestrictionsSample()
4{
5
6 // Assumes User is a valid UPubnubChatUser (e.g. from GetUser)
7
8 // Callback for when the operation completes (returns restrictions across channels)
9 FOnPubnubChatGetRestrictionsResponseNative Callback;
10 // ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
11 Callback.BindUObject(this, &ASample_ChatUser::OnGetChannelsRestrictionsResponse);
12 User->GetChannelsRestrictionsAsync(Callback);
13}
14
15// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
show all 20 linesAll users on one channel
Check mute or ban restrictions for all members of a channel with GetUsersRestrictions().
Method signature
1Channel->GetUsersRestrictions(
2 int Limit = 0,
3 FPubnubMembershipSort Sort = FPubnubMembershipSort(),
4 FPubnubPage Page = FPubnubPage()
5);
Limit#- Number of objects to return in response.
Page#- Object used for pagination to define which previous or next result page you want to fetch.
- property of Page:
Next# - Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
- property of Page:
Prev# - Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
nextparameter is supplied. Sort#- Struct used to specify a property to sort by and sort direction. Available options are
id,name, andupdated. Useascordescto specify the sorting direction. By default, the items are sorted by the last updated date.
Output
FPubnubChatGetRestrictionsResult#- Returned object containing these fields:
Result,Restrictions,Page, andTotal. - property of FPubnubChatGetRestrictionsResult:
Result# - Operation status.
- property of FPubnubChatGetRestrictionsResult:
Restrictions# - Array containing restrictions.
- property of Restrictions:
UserID# - ID of the restricted user.
- property of Restrictions:
ChannelID# - ID of the channel.
- property of Restrictions:
Ban# - Info whether the user is banned from the given channel.
- property of Restrictions:
Mute# - Info whether the user is muted on the given channel.
- property of Restrictions:
Reason# - Reason why the user was banned or muted.
- property of FPubnubChatGetRestrictionsResult:
Page# - Object used for pagination to define which previous or next result page you want to fetch.
- property of Page:
Next# - Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
- property of Page:
Prev# - Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
Nextparameter is supplied. - property of FPubnubChatGetRestrictionsResult:
Total# - Total number of restrictions.
Sample code
List all mute and ban restrictions set for the support channel.
1
2// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
3void ASample_ChatChannel::GetUsersRestrictionsSample()
4{
5
6 // Assumes Channel is a valid UPubnubChatChannel (e.g. from GetChannel)
7
8 // Callback for when the operation completes (returns list of restrictions)
9 FOnPubnubChatGetRestrictionsResponseNative Callback;
10 // ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
11 Callback.BindUObject(this, &ASample_ChatChannel::OnGetUsersRestrictionsResponse);
12 Channel->GetUsersRestrictionsAsync(Callback);
13}
14
15// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
show all 20 linesSecure moderation
Client-side UI restrictions (hiding channels, disabling input) can be bypassed. Secure with server-side logic using Access Manager, plus optional client-side feedback.
Server-side restrictions
Use Access Manager with Chat SDK methods to grant/revoke permissions based on muting/banning restrictions.
Recommended workflow:
- Admin sets restrictions via dashboard (e.g., Channel Monitor)
- Get moderation restrictions for users
- Call Access Manager API to generate/revoke tokens
Implementation steps:
-
Enable Access Manager in the Admin Portal.
-
Initialize Chat SDK with
Auth Keyon the frontend to authenticate users and grant access to PubNub resources. -
Initialize backend with
Secret Keyusing the Unreal SDK to secure your PubNub instance.tip
Secret Keysigns and verifies messages for Access Manager. Never expose to clients. -
Get user permissions - Retrieve restrictions with Get user details and Check restrictions, then convert to permission format (read/write/access per channel).
-
Generate authorization token - Assign an access token with channel permissions and validity period.
tip
See Permissions for the complete operation-to-permission mapping.
Short TTLs recommended
Use short-lived tokens (TTLs) for up-to-date restrictions.
-
Listen for moderation events - Listen for the
moderationevent type (banned,muted, orlifted). -
Act on moderation events - Update permissions and generate new tokens as needed.
Client-side restrictions
With server-side permissions enforced, add optional client-side UI feedback. Read moderation restrictions to display popup messages or icons informing users about their mute/ban status before they attempt restricted actions.
Listen to moderation events
Subscribe to real-time moderation changes for a user with StreamRestrictions(). Bind the user's OnRestrictionChanged delegate before calling this method.
| Delegate | Type | Payload |
|---|---|---|
OnRestrictionChanged | FOnPubnubChatUserRestrictionChanged | FPubnubChatRestriction containing Ban (bool), Mute (bool), Reason (FString), and ChannelID (FString). |
Method signature
1User->StreamRestrictions();
Output
| Type | Description |
|---|---|
FPubnubChatOperationResult | Contains Error and ErrorMessage. Check Error to determine if the subscription started successfully. |
Sample code
Actor.h
1UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|ChatUser")
2void StreamRestrictionsSample();
3
4void OnRestrictionChanged(const FPubnubChatRestriction& Restriction);
Actor.cpp
1
2// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
3void ASample_ChatUser::StreamRestrictionsSample()
4{
5
6 // Assumes User is a valid UPubnubChatUser (e.g. from GetCurrentUser)
7
8 // Bind to receive moderation restriction changes for this user
9 User->OnRestrictionChangedNative.AddUObject(this, &ASample_ChatUser::OnRestrictionChanged);
10
11 // Start streaming restriction events
12 User->StreamRestrictionsAsync(nullptr);
13
14 // When restriction events are no longer needed, stop streaming
15 User->StopStreamingRestrictionsAsync(nullptr);
show all 22 linesStopping updates
To stop receiving moderation events, call StopStreamingRestrictions() on the user.
1User->StopStreamingRestrictions();
Output
| Type | Description |
|---|---|
FPubnubChatOperationResult | Contains Error and ErrorMessage. |