Create users

CreateUser() creates a new user (User object) with a unique User ID.

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.

Method signature

API limits

To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.

Output

TypeDescription
UPubnubUser*Returned object containing the new user data.

Errors

If you try to create a user without providing their ID, you will receive the ID is required error. If you try to create a user that already exists, you will receive the User with this ID already exists error.

Basic usage

Create a user with an ID of support_agent_15. Specify their name, avatar, and custom attributes, such as their title and the LinkedIn profile URL.

#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");

// Define user data
FString UserID = "UniqueUser123";

FPubnubChatUserData UserData;
UserData.UserName = "JohnDoe";
UserData.ExternalID = "External123";
UserData.ProfileUrl = "http://example.com/profile/johndoe.jpg";
show all 22 lines
Last updated on