On this page

List all users

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

icon

Usage in Blueprints and C++


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

Output

ParameterDescription
FPubnubUsersResponseWrapper
Type: struct
Returned object containing three fields: Users, Page, and Total.
 → Users
Type: TArray<UPubnubUser*>
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

Fetch all existing user IDs.

1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9FPubnubUsersResponseWrapper 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.

1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9FPubnubUsersResponseWrapper Users = Chat->GetUsers();
10// Fetch the first 25 users (result page 1)
11int Limit = 25;
12FPubnubUsersResponseWrapper UsersResponsePage1 = Chat->GetUsers("", "", Limit);
13
14// Process the first page of users
15for (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.

1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9FString Filter = "status=='deleted'";
10
11// Fetch all archived users with the filter applied
12FPubnubUsersResponseWrapper ArchivedUsersResponse = Chat->GetUsers(Filter);
13
14// Process and log the archived users
15for (UPubnubUser* User : ArchivedUsersResponse.Users)
show all 19 lines
Last updated on