> ## 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.

# PFLobbyAddMember

> PFLobbyAddMember reference for the PlayFab Multiplayer C++ SDK, used to add a local user as a new member of an existing lobby created or joined by the title.

Add a local user as a member to the lobby.

## Syntax

```cpp theme={null}
HRESULT PFLobbyAddMember(  
    PFLobbyHandle lobby,  
    const PFEntityKey* localUser,  
    uint32_t memberPropertyCount,  
    const char* const* memberPropertyKeys,  
    const char* const* memberPropertyValues,  
    void* asyncContext  
)  
```

### Parameters

**`lobby`**   PFLobbyHandle

The handle of the lobby.

**`localUser`**   [PFEntityKey\*](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/pfentitykey_clientsdk)

The PlayFab Entity Key of the local user to add to the lobby as a member.

**`memberPropertyCount`**   uint32\_t\
*input in range `0,PFLobbyMaxMemberPropertyCount`*

The number of initial member properties to set for this user when they join the lobby.

**`memberPropertyKeys`**   char\* const\*\
*input array of size `memberPropertyCount`*

The keys of the initial member properties to set for this user when they join the lobby.

**`memberPropertyValues`**   char\* const\*\
*input array of size `memberPropertyCount`*

The values of the initial member properties to set for this user when they join the lobby.

**`asyncContext`**   void\*\
*optional*

An optional, app-defined, pointer-sized context value that can be used to associate the completion state change with this call.

### Return value

Type: HRESULT

`S_OK` if the call succeeded or an error code otherwise. The human-readable form of the error code can be retrieved via [PFMultiplayerGetErrorMessage()](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayergeterrormessage).

## Remarks

This is an asynchronous operation. Upon successful completion, the title will be provided a [PFLobbyMemberAddedStateChange](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbymemberaddedstatechange) followed by a [PFLobbyAddMemberCompletedStateChange](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbyaddmembercompletedstatechange) with the [PFLobbyAddMemberCompletedStateChange::result](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbyaddmembercompletedstatechange) field set to `S_OK`. Upon a failed completion, the title will be provided a [PFLobbyAddMemberCompletedStateChange](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbyaddmembercompletedstatechange) with the [PFLobbyAddMemberCompletedStateChange::result](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbyaddmembercompletedstatechange) field set to a failure hresult. <br /><br /> This method is used to add another local PlayFab entity to a pre-existing lobby object. Because the lobby object must have already been created either via a call to [PFMultiplayerCreateAndJoinLobby](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pfmultiplayercreateandjoinlobby) or [PFMultiplayerJoinLobby](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pfmultiplayerjoinlobby), this method is primarily useful for multiple local user scenarios.   <br /><br /> This is an asynchronous operation. The member added via this method will not be reflected in the lists returned by [PFLobbyGetMembers](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pflobbygetmembers) until the asynchronous operation successfully completes and a `PFLobbyMemberAddedStateChange` struct is provided by [PFMultiplayerStartProcessingLobbyStateChanges](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pfmultiplayerstartprocessinglobbystatechanges).

## Requirements

**Header:** PFLobby.h

## See also

[PFLobby members](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/pflobby_members)


## Related topics

- [PFLobbyMemberAddedStateChange](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbymemberaddedstatechange.md)
- [PFLobbyGetMemberProperty](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pflobbygetmemberproperty.md)
- [PFLobbyGetMemberPropertyKeys](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pflobbygetmemberpropertykeys.md)
- [PFLobbyDisconnectingStateChange](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbydisconnectingstatechange.md)
- [PFLobbyGetMemberConnectionStatus](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pflobbygetmemberconnectionstatus.md)
