Skip to main content

Find user by display name

You can fetch a user account based on a display name, but only for Epic Games accounts, and only for those accounts that are on your Epic Games friends list.

caution

This only works for Epic Games accounts on the player's friends list, and only if the player has signed in with their Epic Games account.

Query a user by their display name

To lookup a user by their display name, call QueryUserIdMapping on the user interface, like so:

#include "OnlineSubsystem.h"
#include "OnlineSubsystemUtils.h"
#include "Interfaces/OnlineUserInterface.h"

// ...

IOnlineSubsystem *Subsystem = Online::GetSubsystem(WorldContextObject->GetWorld());
IOnlineIdentityPtr Identity = Subsystem->GetIdentityInterface();
IOnlineUserPtr User = Subsystem->GetUserInterface();

User->QueryUserIdMapping(
*Identity->GetUniquePlayerId(0) /* The local user looking up the accounts */,
DisplayNameInput /* The display name to search */,
IOnlineUser::FOnQueryUserMappingComplete::CreateLambda([](
bool bWasSuccessful,
const FUniqueNetId &UserId,
const FString &DisplayNameOrEmail,
const FUniqueNetId &FoundUserId,
const FString &Error)
{
// If bWasSuccessful, then the user's ID is in FoundUserId.
}));