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);
| Parameter | Required for Chat | Required for User | Required for Channel | Description |
|---|---|---|---|---|
RestrictionType: FPubnubChatRestrictionDefault: n/a | Yes | No | No | Struct containing UserID, ChannelID, Ban, Mute, and Reason fields. Used by Chat only. |
ChannelIDType: FStringDefault: n/a | No | Yes | No | ID of the channel on/from which the user should be muted or banned. Used by User and Channel. |
UserIDType: FStringDefault: n/a | No | No | Yes | Unique User ID of the user to mute or ban. Used by Channel only. |
BanType: boolDefault: n/a | No | Yes | Yes | Set to true to ban the user from the channel or to false to unban them. |
MuteType: boolDefault: n/a | No | Yes | Yes | Set to true to mute the user on the channel or to false to unmute them. |
ReasonType: FStringDefault: "" | No | No | No | Reason why you want to ban or mute the user. |
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++
11 -
SetRestrictions()(on theUserobject)- C++
- Blueprint
1 -
SetRestrictions()(on theChannelobject)- C++
- Blueprint
1
Ban
Ban support_agent_15 from the support channel.
-
SetRestrictions()(on theChatobject)- C++
11 -
SetRestrictions()(on theUserobject — ban example)1User->SetRestrictionsAsync("support", true, false, nullptr, "Banned for sending pictures of pineapple pizza."); -
SetRestrictions()(on theChannelobject)- C++
- Blueprint
1
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
| Parameter | Description |
|---|---|
User->GetChannelRestrictions()Type: FPubnubChatGetRestrictionResult | Returned object containing Result and Restriction. |
Channel->GetUserRestrictions()Type: FPubnubChatGetRestrictionResult | Returned object containing Result and Restriction. |
→ ResultType: FPubnubChatOperationResult | Operation status. |
→ RestrictionType: FPubnubChatRestriction | Restriction details. |
→ UserIDType: FString | ID of the restricted user. |
→ ChannelIDType: FString | ID of the channel. |
→ BanType: bool | Info whether the user is banned from the channel. |
→ MuteType: bool | Info whether the user is muted on the channel. |
→ ReasonType: FString | 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
1 -
GetUserRestrictions()- C++
- Blueprint
1
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);
| Parameter | Description |
|---|---|
LimitType: intDefault: 100 | Number of objects to return in response. The default (and maximum) value is 100. |
PageType: FPubnubPageDefault: n/a | Object used for pagination to define which previous or next result page you want to fetch. |
→ NextType: FStringDefault: n/a | 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. |
→ PrevType: FStringDefault: n/a | 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 next parameter is supplied. |
SortType: FPubnubMembershipSortDefault: n/a | Struct used to specify a property to sort by and sort direction. Available options are id, name, and updated. Use asc or desc to specify the sorting direction. By default, the items are sorted by the last updated date. |
Output
| Parameter | Description |
|---|---|
FPubnubChatGetRestrictionsResultType: struct | Returned object containing these fields: Result, Restrictions, Page, and Total. |
→ ResultType: FPubnubChatOperationResult | Operation status. |
→ RestrictionsType: TArray<FPubnubChatRestriction> | Array containing restrictions. |
→ UserIDType: FString | ID of the restricted user. |
→ ChannelIDType: FString | ID of the channel containing user restrictions. |
→ BanType: bool | Info whether the user is banned from the given channel. |
→ MuteType: bool | Info whether the user is muted on the given channel. |
→ ReasonType: FString | Reason why the user was banned or muted. |
→ PageType: FPubnubPage | Object used for pagination to define which previous or next result page you want to fetch. |
→ NextType: FString | 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. |
→ PrevType: FString | 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 Next parameter is supplied. |
→ TotalType: int | Total number of restrictions. |
Sample code
List all mute and ban restrictions set for a user.
1
All 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);
| Parameter | Description |
|---|---|
LimitType: intDefault: 0 (server default) | Number of objects to return in response. |
PageType: FPubnubPageDefault: n/a | Object used for pagination to define which previous or next result page you want to fetch. |
→ NextType: FStringDefault: n/a | 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. |
→ PrevType: FStringDefault: n/a | 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 next parameter is supplied. |
SortType: FPubnubMembershipSortDefault: n/a | Struct used to specify a property to sort by and sort direction. Available options are id, name, and updated. Use asc or desc to specify the sorting direction. By default, the items are sorted by the last updated date. |
Output
| Parameter | Description |
|---|---|
FPubnubChatGetRestrictionsResultType: struct | Returned object containing these fields: Result, Restrictions, Page, and Total. |
→ ResultType: FPubnubChatOperationResult | Operation status. |
→ RestrictionsType: TArray<FPubnubChatRestriction> | Array containing restrictions. |
→ UserIDType: FString | ID of the restricted user. |
→ ChannelIDType: FString | ID of the channel. |
→ BanType: bool | Info whether the user is banned from the given channel. |
→ MuteType: bool | Info whether the user is muted on the given channel. |
→ ReasonType: FString | Reason why the user was banned or muted. |
→ PageType: FPubnubPage | Object used for pagination to define which previous or next result page you want to fetch. |
→ NextType: FString | 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. |
→ PrevType: FString | 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 Next parameter is supplied. |
→ TotalType: int | Total number of restrictions. |
Sample code
List all mute and ban restrictions set for the support channel.
1
Secure 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
1
Actor.cpp
1
Stopping updates
To stop receiving moderation events, call StopStreamingRestrictions() on the user.
1User->StopStreamingRestrictions();
Output
| Type | Description |
|---|---|
FPubnubChatOperationResult | Contains Error and ErrorMessage. |