> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# chat_manager::add_local_user

> chat_manager::add_local_user

# chat\_manager::add\_local\_user

Adds a local user to the local chat\_manager instance.

## Syntax

```cpp theme={null}
chat_user* add_local_user(  
    PCWSTR xboxUserId  
)  
```

### Parameters

*xboxUserId*   \_In\_\
Type: PCWSTR

The XBOX User ID of the local user to add.

### Return value

Type: chat\_user\*

## Remarks

All local users added to the Game Chat 2 instance need to be added with [XUserAddAsync](/reference/system/xuser/functions/xuseraddasync) first.

The user will be added unconditionally, unless the total number of local and remote users is equal to the max user count that was indicated in chat\_manager::initialize().

The return value is a pointer to the chat\_user object associated with this user. If the XBOX User ID is invalid, the user's chat\_indicator value will be game\_chat\_user\_chat\_indicator::platform\_restricted.

A typical pattern would be:

```cpp theme={null}
chat_user* newLocalChatUser = chat_manager::singleton_instance().add_local_user(&amp;lt;local_user_xuid&amp;gt;);

size_t chatUserCount; 
chat_user_array chatUsers; 
chat_manager::singleton_instance().get_remote_chat_users(&chatUserCount, &chatUsers); 
for (uint32_t chatUserIndex = 0; chatUserIndex < chatUsercount; ++chatUserIndex) 
{ 
    chat_user* chatUser = chatUsers[chatUserIndex]; 
    game_chat_communication_relationship_flags relationship = game_chat_communication_relationship_flags::none; 
    if (chatUser can send and receive to/from newLocalChatUser) 
    { 
        relationship = c_communicationRelationshipSendAndReceiveAll; 
    } 
    else if (chatUser can send to newLocalChatUser) 
    { 
        relationship = c_communicationRelationshipSendAll; 
    } 
    else if (chatUser can receive from newLocalChatUser) 
    { 
        relationship = c_communicationRelationshipReceiveAll; 
    } 

    newLocalChatUser->set_communication_relationship(chatUser, relationship); 
} 
```

## Requirements

**Header:** GameChat2.h

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## See also

[chat\_manager](/reference/chat/gamechat2/classes/chat_manager/chat_manager)\
[chat\_user](/reference/chat/gamechat2/classes/chat_user/chat_user)\
[chat\_manager::add\_remote\_user](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_add_remote_user)\
[chat\_manager::remove\_user](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_remove_user)


## Related topics

- [chat_manager::get_chat_users](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_get_chat_users.md)
- [Using the Game Chat 2 C++ API](/services/xbox-services/multiplayer/chat/game-chat2/using-game-chat-2.md)
- [chat_manager::add_remote_user](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_add_remote_user.md)
- [chat_user::local](/reference/chat/gamechat2/classes/chat_user/methods/chat_user_local_function_2.md)
- [chat_manager::remove_user](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_remove_user.md)
