Manage user details
Retrieve user details from your app.
Get user details
GetUser() returns data about a specific user, including all custom metadata by default.
Requires App Context
Enable App Context in the Admin Portal to store user data.
Method signature
- Blueprint
- C++ / Input parameters
1Chat->GetUser(FString UserID)
* required
| Parameter | Description |
|---|---|
UserID *Type: FString | Unique user identifier. |
Output
| Type | Description |
|---|---|
UPubnubUser* | Returned object containing the user metadata or a null value if the user doesn't exist. |
Sample code
Get details on user support_agent_15.
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
9// Define user ID
10FString UserID = "support_agent_15";
11
12// Get the user and save the reference
13UPubnubUser* User = Chat->GetUser(UserID);
Get current user
CurrentUser() returns the current chat user.
Requires App Context
Enable App Context in the Admin Portal to store user data.
Method signature
- Blueprint
- C++ / Input parameters
1Chat->CurrentUser();
Output
| Type | Description |
|---|---|
UPubnubUser* | Returned User object. |
Sample code
Return the current chat user.
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
9// Define user ID
10FString UserID = "support_agent_15";
11
12// Get the user and save the reference
13UPubnubUser* User = Chat->CurrentUser();
Get user ID
GetUserID() returns the current chat user's ID.
Method signature
- Blueprint
- C++ / Input parameters
1User->GetUserID();
Output
| Type | Description |
|---|---|
FString* | Returned user ID. |
Sample code
Return the current chat user's ID.
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
9// Define user ID
10FString UserID = "support_agent_15";
11
12// Get the user and save the reference
13UPubnubUser* User = Chat->CurrentUser();
14
15FString ReturnedUserID = User->GetUserID();
Get user data
GetUserData() returns the current chat user's data.
Method signature
- Blueprint
- C++ / Input parameters
1User->GetUserData();
Output
| Type | Description |
|---|---|
FPubnubChatUserData* | Returned user data. |
Sample code
Return the current chat user's data.
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
9// Define user ID
10FString UserID = "support_agent_15";
11
12// Get the user and save the reference
13UPubnubUser* User = Chat->CurrentUser();
14
15FPubnubChatUserData UserData = User->GetUserData();