On this page

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.

icon

Usage in Blueprints and C++


Asynchronous and synchronous method execution

Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.

  • Asynchronous methods (Async suffix) return void and 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 Native suffix (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 moderation event (muted or banned)
  • A moderation membership is created with PUBNUB_INTERNAL_MODERATION_ prefix (secured via Access Manager, filtered from GetMemberships() results)
  • Lifting restrictions removes the moderation membership and creates a lifted event

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

  • 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);
ParameterRequired for ChatRequired for UserRequired for ChannelDescription
Restriction
Default:
n/a
Yes
No
No
Struct containing UserID, ChannelID, Ban, Mute, and Reason fields. Used by Chat only.
ChannelID
Type: FString
Default:
n/a
No
Yes
No
ID of the channel on/from which the user should be muted or banned. Used by User and Channel.
UserID
Type: FString
Default:
n/a
No
No
Yes
Unique User ID of the user to mute or ban. Used by Channel only.
Ban
Type: bool
Default:
n/a
No
Yes
Yes
Set to true to ban the user from the channel or to false to unban them.
Mute
Type: bool
Default:
n/a
No
Yes
Yes
Set to true to mute the user on the channel or to false to unmute them.
Reason
Type: FString
Default:
""
No
No
No
Reason why you want to ban or mute the user.

Output

MethodReturn type
User->SetRestrictions()
FPubnubChatOperationResult
Chat->SetRestrictions()
FPubnubChatOperationResult
Channel->SetRestrictions()
FPubnubChatOperationResult

Sample code

Mute

Mute support_agent_15 on the support channel.

  • SetRestrictions() (on the Chat object)

    1
    
    1
    
  • SetRestrictions() (on the User object)

    1
    
  • SetRestrictions() (on the Channel object)

    1
    

Ban

Ban support_agent_15 from the support channel.

  • SetRestrictions() (on the Chat object)

    1
    
    1
    
  • SetRestrictions() (on the User object — ban example)

    1User->SetRestrictionsAsync("support", true, false, nullptr, "Banned for sending pictures of pineapple pizza.");
  • SetRestrictions() (on the Channel object)

    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

  • User->GetChannelRestrictions()

    1User->GetChannelRestrictions(UPubnubChatChannel* Channel)
  • Channel->GetUserRestrictions()

    1Channel->GetUserRestrictions(UPubnubChatUser* User);
ParameterRequired in User->GetChannelRestrictions()Required in Channel->GetUserRestrictions()Description
Channel
Type: UPubnubChatChannel*
Default:
n/a
Yes
No
Channel object on/from which the user can be muted or banned.
User
Type: UPubnubChatUser*
Default:
n/a
No
Yes
User object that can be muted or banned.
Output
ParameterDescription
User->GetChannelRestrictions()
Type: FPubnubChatGetRestrictionResult
Returned object containing Result and Restriction.
Channel->GetUserRestrictions()
Type: FPubnubChatGetRestrictionResult
Returned object containing Result and Restriction.
 → Result
Type: FPubnubChatOperationResult
Operation status.
 → Restriction
Type: FPubnubChatRestriction
Restriction details.
   → UserID
Type: FString
ID of the restricted user.
   → ChannelID
Type: FString
ID of the channel.
   → Ban
Type: bool
Info whether the user is banned from the channel.
   → Mute
Type: bool
Info whether the user is muted on the channel.
   → Reason
Type: 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()

    1
    
  • GetUserRestrictions()

    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);
* required
ParameterDescription
Limit
Type: int
Default:
100
Number of objects to return in response. The default (and maximum) value is 100.
Page
Type: FPubnubPage
Default:
n/a
Object used for pagination to define which previous or next result page you want to fetch.
 → Next
Type: FString
Default:
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.
 → Prev
Type: FString
Default:
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.
Sort
Type: FPubnubMembershipSort
Default:
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
ParameterDescription
FPubnubChatGetRestrictionsResult
Type: struct
Returned object containing these fields: Result, Restrictions, Page, and Total.
 → Result
Type: FPubnubChatOperationResult
Operation status.
 → Restrictions
Type: TArray<FPubnubChatRestriction>
Array containing restrictions.
   → UserID
Type: FString
ID of the restricted user.
   → ChannelID
Type: FString
ID of the channel containing user restrictions.
   → Ban
Type: bool
Info whether the user is banned from the given channel.
   → Mute
Type: bool
Info whether the user is muted on the given channel.
   → Reason
Type: FString
Reason why the user was banned or muted.
 → Page
Type: FPubnubPage
Object used for pagination to define which previous or next result page you want to fetch.
   → Next
Type: 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.
   → Prev
Type: 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.
 → Total
Type: 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);
* required
ParameterDescription
Limit
Type: int
Default:
0 (server default)
Number of objects to return in response.
Page
Type: FPubnubPage
Default:
n/a
Object used for pagination to define which previous or next result page you want to fetch.
 → Next
Type: FString
Default:
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.
 → Prev
Type: FString
Default:
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.
Sort
Type: FPubnubMembershipSort
Default:
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
ParameterDescription
FPubnubChatGetRestrictionsResult
Type: struct
Returned object containing these fields: Result, Restrictions, Page, and Total.
 → Result
Type: FPubnubChatOperationResult
Operation status.
 → Restrictions
Type: TArray<FPubnubChatRestriction>
Array containing restrictions.
   → UserID
Type: FString
ID of the restricted user.
   → ChannelID
Type: FString
ID of the channel.
   → Ban
Type: bool
Info whether the user is banned from the given channel.
   → Mute
Type: bool
Info whether the user is muted on the given channel.
   → Reason
Type: FString
Reason why the user was banned or muted.
 → Page
Type: FPubnubPage
Object used for pagination to define which previous or next result page you want to fetch.
   → Next
Type: 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.
   → Prev
Type: 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.
 → Total
Type: 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:

  1. Admin sets restrictions via dashboard (e.g., Channel Monitor)
  2. Get moderation restrictions for users
  3. Call Access Manager API to generate/revoke tokens

Implementation steps:

  1. Enable Access Manager in the Admin Portal.

  2. Initialize Chat SDK with Auth Key on the frontend to authenticate users and grant access to PubNub resources.

  3. Initialize backend with Secret Key using the Unreal SDK to secure your PubNub instance.

    tip

    Secret Key signs and verifies messages for Access Manager. Never expose to clients.

  4. Get user permissions - Retrieve restrictions with Get user details and Check restrictions, then convert to permission format (read/write/access per channel).

  5. 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.

  6. Listen for moderation events - Listen for the moderation event type (banned, muted, or lifted).

  7. 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.

DelegateTypePayload
OnRestrictionChanged
FOnPubnubChatUserRestrictionChanged
FPubnubChatRestriction containing Ban (bool), Mute (bool), Reason (FString), and ChannelID (FString).

Method signature

1User->StreamRestrictions();

Output

TypeDescription
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

TypeDescription
FPubnubChatOperationResult
Contains Error and ErrorMessage.
Last updated on