---
source_url: https://www.pubnub.com/docs/chat/unity-chat-sdk/learn/chat-entities/user
title: User object
updated_at: 2026-06-12T11:23:21.192Z
---

> 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


# User object

`User` represents a single user in a chat.

## Properties

`User` has the following properties:

```csharp
public class User : UniqueChatEntity {
    public string Id { get; protected set; }
    public string UserName { get; }
    public string ExternalId { get; }
    public string ProfileUrl { get; }
    public string Email { get; }
    public Dictionary<string, object> CustomData { get; }
    public string Status { get; }
    public string DataType { get; }
    public bool Active { get; }
    public string LastActiveTimeStamp { get; }
}
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| Id | string | Optional |  | Unique identifier for the user. |
| UserName | string | Optional |  | Display name or username of the user. |
| ExternalId | string | Optional |  | Identifier for the user from an external system, such as a database or CRM. |
| ProfileUrl | string | Optional |  | URL to the user's profile or avatar image. |
| Email | string | Optional |  | User's email address. |
| CustomData | Dictionary<string, | Optional |  | Any custom data that you want to store for the user. |
| Status | string | Optional |  | Current status of the user (e.g., `online`, `offline`, `away`). |
| DataType | string | Optional |  | Type of user's data. |
| Active | bool | Optional |  | Returned info on whether the user is active (`true`) or not active (`false`) on the channel. The returned value depends strictly on how you configure your chat app during [initialization](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/configuration#initialize-pubnub) - if you set the `StoreUserActivityInterval` parameter to the default `60000` milliseconds (1 minute) and the user has been active in the app within the last 1 minute (based on their `LastActiveTimeStamp` property), accessing the `Active` property returns `true`. |
| LastActiveTimeStamp | string | Optional |  | Timestamp for the last time the user was active in a chat app. |

:::tip API limits
To learn about the maximum length of parameters used to set user metadata, refer to [REST API docs](https://www.pubnub.com/docs/sdks/rest-api/set-user-metadata).
:::

### Events

The `User` object has the following events:

```csharp
// Event triggered when the user is updated.
// Call StreamUpdates(true) to enable this callback.
public event Action<User> OnUpdated;
// Event triggered when the user is hard-deleted from App Context.
// Call StreamUpdates(true) to enable this callback.
public event Action OnDeleted;
// Event triggered when a user is mentioned in a message.
// Call StreamMentionEvents(true) to enable this callback.
public event Action<Mention> OnMentioned;
// Event triggered when a user is invited to a channel.
// Call StreamInviteEvents(true) to enable this callback.
public event Action<Invite> OnInvited;
// Event triggered when a user's moderation restrictions change.
// Call StreamModerationEvents(true) to enable this callback.
public event Action<ChannelRestriction> OnRestrictionChanged;
```

#### Example

An event that is triggered when the user is updated by the server.

```csharp
using System.Threading.Tasks;
using PubnubApi;
using PubnubChatApi;
using UnityEngine;

// Configuration
PubnubChatConfig chatConfig = new PubnubChatConfig();
        
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize Unity Chat
var chatResult = await UnityChat.CreateInstance(chatConfig, pnConfiguration);
if (!chatResult.Error)
{
    chat = chatResult.Result;
}
// Get a user
var userResult = await chat.GetUser("user_id");
if (!userResult.Error)
{
    var user = userResult.Result;
            
    user.OnUpdated += (user) =>
    {
        Debug.Log("User metadata updated!");
    };
}
```

## Methods

You can call the following methods on the `User` object.

Click on each method for more details.

### Standard methods

* [Delete()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/delete)
* [GetChannelRestrictions()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/moderation#one-user-on-one-channel)
* [GetChannelsRestrictions()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/moderation#all-users-on-all-channels)
* [GetMembership()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/membership#check-membership)
* [GetMemberships()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/membership#get-membership)
* [IsMemberOn()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/membership#check-membership)
* [IsPresentOn()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/presence#check-users-channel-presence)
* [SetRestriction()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/moderation#mute-or-ban-users)
* [Update()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/updates#update-user-details)
* [WherePresent()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/presence#return-channels-where-user-is-present)

### Streaming methods

These methods register or unregister real-time event subscriptions. Each streaming method activates one or more of the events listed in the [Events](#events) section above.

* [StreamInviteEvents()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/invite#listen-to-invite-events)
* [StreamMentionEvents()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/mentions#show-notifications-for-mentions)
* [StreamModerationEvents()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/moderation#listen-to-moderation-events)
* [StreamUpdates()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/updates#get-user-updates)
* [StreamUpdatesOn()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/updates#get-user-updates)

## Use case

`User` methods enable:

* [Creating and managing](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/create) users
* Configuring channel [memberships](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/membership)
* Checking if a user is a [member](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/membership#check-membership) of a channel
* [Mentioning](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/mentions) others in conversations
* Checking user [presence](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/presence) status