question

Amirhossein Hakimnejad avatar image
Amirhossein Hakimnejad asked

Can't get player email from title player account using GetPlayerProfile

Hi

I am trying to read player email address in title player account by calling server.GetPlayerProfile({"PlayFabId" : currentPlayerId}); from cloudscript.

The problem is that there are no keys in response that contain the player's email. All I get is "PublisherId", "TitleId", "PlayerId", "DisplayName".

Important: I checked the Client Profile Options/Contact email addresses setting from the title settings and the problem is still there.


My title id: 5E0B

Player DataCloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

Server APIGetPlayerProfile can be used to get the player contact email, if you want to get it, you need to fill the ProfileConstraints and set ShowContactEmailAddresses as true, like the following CloudScript sample code.

handlers.getPlayerProfile = function (args, context) {
   
    var request = {
        PlayFabId: currentPlayerId, 
        ProfileConstraints: {
                ShowContactEmailAddresses: true
            }
    };
    var getPlayerProfileResult = server.GetPlayerProfile(request);
    return {profile:getPlayerProfileResult};
};

But if you want to get the player login email, you can use server API GetUserAccountInfo to get it. You can refer to the following code.

handlers.getPlayerAccountInfo = function (args, context) {
   
    var request = {
        PlayFabId: currentPlayerId, 
       
    };
    var getPlayerAccountInfo = server.GetUserAccountInfo(request);
    return {getPlayerAccountInfo:getPlayerAccountInfo};
};
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.