List all users

Get a paginated list of all users and their details using the GetUsers() method.

By default, this method returns all custom user metadata without the need to define that during the call explicitly.

icon

Usage in Blueprints and C++


Requires App Context

To store data about users, you must enable App Context for your app's keyset in the Admin Portal.

If you have Access Manager enabled in your app, uncheck the Disallow Get All User Metadata option in the App Context configuration in the Admin Portal – this way you can get metadata of all users without the need to define that in the permissions schema included in the authentication token.

Method signature

Output

ParameterTypeDescription
FPubnubUsersResponseWrapperstructReturned object containing three fields: Users, Page, and Total.
 → UsersTArray<UPubnubUser*>Array of all matching users.
 → PageFPubnubPageString that lets you either fetch the next (Next) or previous (Prev) result page.
   → NextFStringRandom 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.
   → PrevFStringRandom 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.
 → TotalintTotal number of User objects matching the request query.

Basic usage

Fetch all existing user IDs.

#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();

UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");

FPubnubUsersResponseWrapper Users = Chat->GetUsers();

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.

#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();

UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");

FPubnubUsersResponseWrapper Users = Chat->GetUsers();
// Fetch the first 25 users (result page 1)
int Limit = 25;
FPubnubUsersResponseWrapper UsersResponsePage1 = Chat->GetUsers("", "", Limit);

// Process the first page of users
for (UPubnubUser* User : UsersResponsePage1.Users)
show all 35 lines

Archived users

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

#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();

UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");

FString Filter = "status=='deleted'";

// Fetch all archived users with the filter applied
FPubnubUsersResponseWrapper ArchivedUsersResponse = Chat->GetUsers(Filter);

// Process and log the archived users
for (UPubnubUser* User : ArchivedUsersResponse.Users)
show all 19 lines
Last updated on