On this page

Manage user details

Retrieve user details from your app.

icon

Usage in Blueprints and C++

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

Output

TypeDescription
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

Output

TypeDescription
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

Output

TypeDescription
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

Output

TypeDescription
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();
Last updated on