Updating Player Records


After a player has been created, you might want to change details associated with the player's account such as:

Different people might want to make a user account change:

Here, we'll learn how to:

Change User Details Request

This example shows an Event which takes a string input and sets it as the player's new userName using the ChangeUserDetailsRequest and outputs the response as scriptData.

//String input
//String input

//Create an instance of the ChangeUserDetails request
var changeDetailsRequest = new SparkRequests.ChangeUserDetailsRequest();

//Set the userName. You can also change:
//Language / newPassword / oldPassword / displayName
changeDetailsRequest.userName = string;

//Send request and save response
var response = changeDetailsRequest.Send();

//Output response with scriptData
Spark.setScriptData("response", response);

Deleting Players

You can delete players through Cloud Code using the SparkPlayer.deletePlayer() method. This will delete the data for a player from all Mongo System collections.

Delete with Caution! To avoid any unexpected and disruptive consequences when deleting players, we strongly recommend that you use this method with caution and check first for any Challenges, Teams, Matches, and so on to which the player you intend to delete might belong.