Updating a non logg...
 
Notifications
Clear all

Updating a non logged user

2 Posts
2 Users
0 Reactions
1,266 Views
(@jackmariani)
Posts: 11
Eminent Member
Topic starter
 

I'd like to update a customData of a non logged user.

To do that I should:

1) load the user, using his username

Here I found the following line:

CBManager.instance.LoadUser(123);

I tried changing the id with the username but it doesn't work. Any other option?

2) updating the customData

Then I need simply the following lines:

CBManager.instance.loggedUser.customData["coins"] = 300;
// Send update to web service
CBManager.instance.loggedUser.Update();

 

I think I just need a way to load the player using just his username and I should good to go, right?

Thank you very much.

 
Posted : 04/09/2014 1:53 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

Updating a non-logged user is not allowed for security reason, most web services are protected by checking if a user is currently logged (specifically you cannot edit a user different from the logged one). If you really want to allow it, then you need to make changes to the users web service by removing the check for $LoggedAccount->IsLogged() in both wsLoad() and wsUpdate(), then change the logic in wsUpdate with the account load that you see in wsLoad to use an account that is not $LoggedAccount. It needs some knowledge of PHP language of course.

PS: in the point "2" of your message you're changing the customData of the currently logged user, not the user you was loading with LoadUser (in order to make what you're looking for, you need to add event handlers for CBManager.instance.OnUserLoaded and then do changes to the object passed to the event function and call Update() on it). Look at the documentation for "Load User" to see how it works. Though remember that the default web services need a user logged in order to work correctly, so before you will need to make the changes above.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 04/09/2014 2:36 pm
Share: