---
source_url: https://www.pubnub.com/docs/chat/unity-chat-sdk/learn/chat-entities/user
title: User object
description: Explore the properties and methods of the User object in PubNub's Unity Chat SDK documentation to manage users effectively.
updated_at: 2026-09-30T07:20:08.000Z
---

# User object

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

`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 | Description |
| --- | --- | --- |
| Id | string | Unique identifier for the user. |
| UserName | string | Display name or username of the user. |
| ExternalId | string | Identifier for the user from an external system, such as a database or CRM. |
| ProfileUrl | string | URL to the user's profile or avatar image. |
| Email | string | User's email address. |
| CustomData | Dictionary<string, object> | Any custom data that you want to store for the user. |
| Status | string | Current status of the user (e.g., `online`, `offline`, `away`). |
| DataType | string | Type of user's data. |
| Active | bool | 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.md#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 | 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.md).
:::

### 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.md)
* [`GetChannelRestrictions()`](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/moderation.md#one-user-on-one-channel)
* [`GetChannelsRestrictions()`](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/moderation.md#one-user-on-all-channels)
* [`GetMembership()`](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/membership.md#check-membership)
* [`GetMemberships()`](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/membership.md#get-membership)
* [`IsMemberOn()`](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/membership.md#check-membership)
* [`IsPresentOn()`](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/presence.md#check-users-channel-presence)
* [`SetRestriction()`](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/moderation.md#mute-or-ban-users-as-an-administrator)
* [`Update()`](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/updates.md#update-user-details)
* [`WherePresent()`](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/presence.md#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.md#listen-to-invite-events)
* [`StreamMentionEvents()`](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/mentions.md#show-notifications-for-mentions)
* [`StreamModerationEvents()`](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/moderation.md#listen-to-moderation-events)
* [`StreamUpdates()`](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/updates.md#get-user-updates)
* [`StreamUpdatesOn()`](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/updates.md#get-user-updates)

## Use case

`User` methods enable:

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

Last updated at: 2026-09-30T07:20:08.000Z
