---
source_url: https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/users/list
title: List all users
updated_at: 2026-06-17T11:37:29.006Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# List all users

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

##### Usage in Blueprints and C++

You can use PubNub's functionality via Blueprints or directly in C++ code.

* In Blueprints, you can access PubNub from any Widget or Actor. Start by [initializing chat](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/configuration#initialize-pubnub-chat) using `InitChat` on `UPubnubChatSubsystem`. Afterwards, you can use the returned `UPubnubChat` object reference to call all Chat SDK functions.

:::warning Blueprint functions
The Blueprints provided in the documentation show how you can structure your application and may contain utility methods and elements like buttons that are not part of the Unreal Chat SDK and are meant to serve as guidance.
:::

* In C++, you can use UPubnubChatSubsystem as any other Game Instance Subsystem. #include "Kismet/GameplayStatics.h" #include "Engine/GameInstance.h" #include "PubnubChatSubsystem.h" // ACTION REQUIRED: Replace ASample_ChatSubsystem with name of your Actor class void ASample_ChatSubsystem::InitChatSample() { // Get PubnubChatSubsystem from GameInstance UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this); UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>(); // Initialize Chat - InitChat may fail under some conditions so make sure to check the Result for errors before using the Chat FPubnubChatInitChatResult InitChatResult = PubnubChatSubsystem->InitChat(TEXT("demo"), TEXT("demo"), TEXT("Player_001")); UPubnubChat* PubnubChat = InitChatResult.Chat; } Chat now allows you to call all Chat SDK functions, for example, Chat->GetChannel("my_channel").

:::note 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();
:::

:::note Requires App Context
Enable [App Context](https://youtu.be/9UEoSlngpYI) in the [Admin Portal](https://admin.pubnub.com/) to store user data. If using [Access Manager](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/users/permissions), uncheck `Disallow Get All User Metadata` in the [App Context configuration](https://www.pubnub.com/docs/general/metadata/basics#configuration).
:::

### Method signature

```cpp
Chat->GetUsers(
    int Limit = 0,
    FString Filter = "",
    FPubnubGetAllSort Sort = FPubnubGetAllSort(),
    FPubnubPage Page = FPubnubPage()
);
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| Limit | int | Optional | `0 (server default)` | Number of objects to return in response. |
| Filter | FString | Optional | `""` | Expression used to filter the results. Returns only those users whose properties satisfy the given expression. The filter language is [defined here](https://www.pubnub.com/docs/general/metadata/filtering). |
| Sort | FPubnubGetAllSort | Optional |  | 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 | FPubnubPage | Optional |  | Object used for pagination to define which previous or next result page you want to fetch. |
| > Next | FString | Optional |  | 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 | FString | Optional |  | 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

| Parameter | Description |
| --- | --- |
| `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](https://www.pubnub.com/docs/chat/unreal-chat-sdk/learn/chat-entities/user) matching the request query. |

### Sample code

:::tip 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

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|Chat|User")
void GetUsersSample();

UFUNCTION()
void OnGetUsersResponse(const FPubnubChatGetUsersResult& Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::GetUsersSample()
{
	// snippet.hide
	UPubnubChat* Chat = nullptr;
	// snippet.show

	// Assumes Chat is a valid and initialized instance of UPubnubChat

	// Bind a callback with signature matching FOnPubnubChatGetUsersResponseNative, then call Async
	FOnPubnubChatGetUsersResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
	Callback.BindUObject(this, &ASample_Chat::OnGetUsersResponse);
	Chat->GetUsersAsync(Callback, 20);
}

// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::OnGetUsersResponse(const FPubnubChatGetUsersResult& Result)
{
	if (Result.Result.Error) { return; }
	for (UPubnubChatUser* User : Result.Users)
	{
		/* show in UI, etc. */
	}
	// Use Result.Page for pagination (Result.Page.Next / Result.Page.Prev)
}
```

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

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|Chat|User")
void GetUsersPaginationSample();
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::GetUsersPaginationSample()
{
	// snippet.hide
	UPubnubChat* Chat = nullptr;
	// snippet.show

	// Assumes Chat is a valid and initialized instance of UPubnubChat

	// Fetch first 25 users
	FPubnubChatGetUsersResult UsersResponsePage1 = Chat->GetUsers(25);

	for (UPubnubChatUser* User : UsersResponsePage1.Users)
	{
		FString UserID = User->GetUserID();
		UE_LOG(LogTemp, Log, TEXT("User ID: %s"), *UserID);
	}

	// Fetch next 25 users using the 'next' page token from the previous response
	if (!UsersResponsePage1.Page.Next.IsEmpty())
	{
		FPubnubPage NextPage;
		NextPage.Next = UsersResponsePage1.Page.Next;

		FPubnubChatGetUsersResult UsersResponsePage2 = Chat->GetUsers(25, "", FPubnubGetAllSort(), NextPage);

		for (UPubnubChatUser* User : UsersResponsePage2.Users)
		{
			FString UserID = User->GetUserID();
			UE_LOG(LogTemp, Log, TEXT("User ID: %s"), *UserID);
		}
	}
}
```

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

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|Chat|User")
void GetUsersArchivedSample();
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::GetUsersArchivedSample()
{
	// snippet.hide
	UPubnubChat* Chat = nullptr;
	// snippet.show

	// Assumes Chat is a valid and initialized instance of UPubnubChat

	// Fetch all archived (soft-deleted) users
	FString Filter = "status=='deleted'";
	FPubnubChatGetUsersResult ArchivedUsersResponse = Chat->GetUsers(0, Filter);

	for (UPubnubChatUser* User : ArchivedUsersResponse.Users)
	{
		FString UserId = User->GetUserID();
		UE_LOG(LogTemp, Log, TEXT("Archived User ID: %s"), *UserId);
	}
}
```