question

chairilazmi03 avatar image
chairilazmi03 asked

Delete user display name persists

Hello,

I tried deleting my user using the following code:

handlers.DeleteUsers = function (args, context)
{
    if (args && args.hasOwnProperty("inputValue"))
	{
		server.DeleteUsers(
		{
			PlayFabIds: args.inputValue,
			TitleId: currentTitleId
		});
	}
}

However, the display name still remains hence preventing any new users from using that display name (I set it to be unique for each account).
How do I completely delete my user account along with its display name?

apis
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

·
brendan avatar image
brendan answered

Well first, there is no default "currentTitleId" value - you would need to use script.titleId to get the executing title's ID. However, there is a currentPlayerId, if your inputValue is meant to be the local player's ID (which I would do, since otherwise, this handler would let any player delete any other player). Now technically, the PlayFabIds is an array, but I just tested this and it actually works fine in Cloud Script without the square brackets around the PlayFab ID being specified. But that said, I would use that anyway, to be safe. So I'd recommend using the call like so:

handlers.DeleteThisUser = function(args, context) {
    server.DeleteUsers({
        PlayFabIds: [currentPlayerId],
        TitleId: script.titleId
    });
}

Though technically, I would also add some error checking to the code, as well.

I just tested this both with and without the square brackets on the array, and it works fine in both cases. Now, you'll still see the display name showing up on the Players tab until that account scrolls off, as that's not a realtime query currently - it's driven by the login event history. But the display name is available for re-use at that point (tested that, as well).

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.