On this page

List all users

GetUsers() returns a paginated list of all users with their metadata.

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.

    1Chat->GetUsersAsync(OnGetUsersResponseDelegate);

    You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the Native suffix (for example, FOnPubnubChatGetUsersResponseNative).

  • Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly.

    1FPubnubChatGetUsersResult Result = Chat->GetUsers();
Requires App Context

Enable App Context in the Admin Portal to store user data. If using Access Manager, uncheck Disallow Get All User Metadata in the App Context configuration.

Method signature

1Chat->GetUsers(
2 int Limit = 0,
3 FString Filter = "",
4 FPubnubGetAllSort Sort = FPubnubGetAllSort(),
5 FPubnubPage Page = FPubnubPage()
6);
* required
ParameterDescription
Limit
Type: int
Default:
0 (server default)
Number of objects to return in response.
Filter
Type: FString
Default:
""
Expression used to filter the results. Returns only those users whose properties satisfy the given expression. The filter language is defined here.
Sort
Type: FPubnubGetAllSort
Default:
n/a
Key-value pair of a property to sort by, and a 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.
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.

Output

ParameterDescription
FPubnubChatGetUsersResult
Type: struct
Returned object containing Result, Users, Page, and Total.
 → Result
Type: FPubnubChatOperationResult
Operation result with Error (bool) and ErrorMessage (FString).
 → Users
Type: TArray<UPubnubChatUser*>
Array of all matching users.
 → Page
Type: FPubnubPage
String that lets you either fetch the next (Next) or previous (Prev) result page.
   → 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 User objects matching the request query.

Sample code

Reference code

This example is a self-contained code snippet ready to be run. Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code. Use it as a reference when working with other examples in this document.

Retrieve a paginated list of users asynchronously.

Actor.h
1

Actor.cpp
1

Other examples

Pagination

Get the total number of 25 users and then specify that you want to fetch the results from the next page using a string that was previously returned from the PubNub server.

Actor.h
1

Actor.cpp
1

Archived users

Get all archived users. This request will return all soft-deleted users whose data is still stored in the App Context storage.

Actor.h
1

Actor.cpp
1

Last updated on