WHAT IS | Update the user’s account parameters. |
DONE | Return the ID of the updated user. This ID can be used for performing user-related operations on WordPress (for example, get the list of the user’s posts or uploaded media). |
ERROR | Return the WordPress system error message (see the WP Code Reference). |
USED WP METHODS | wp_update_user |
_ = wpUser.$Update$(%user_id, userParameters%).$Done$(%doneCallback%).$Error$(%errorCallback%).$Run$();
user_id|int
The id of user to update.
__
userParameters|UserParameters
The parameters to update (see the User Parameters paragraph below).
__
doneCallback|function
The function to call when the operation will be completed.
Note: the use of the Done() method is mandatory.
__
errorCallback|(function)
The function to call in case of error.
Note: the use of the Error() method is optional and can be omitted.
{{{#912c9a|WPReply|Data-type|Property or method description}}}
__
.data|string
The ID of the WordPress user.
__
.isOK|bool
true if everything is ok, false in case of error.
__
.isError|bool
true in case of error, false if everything is ok.
__
.error|string
The error message from the Server. It can be a string generated by WordPress through its get_error_message method (see the WP manual).
__
errorType|HttpRequest.Error Enum
The kind of error:
NONE = no error.
HTTP_ERROR = communication error.
SYSTEM_ERROR = UniWP error.
WORDPRESS_ERROR = error message from WordPress REST APIs.
User parameters
The userParameters parameter allows defining the users’ values to modify. This parameter must be an instance of the UserParameters class.
user_login|string
The user’s username.
__
user_pass|string
The user’s password.
__
user_email|string
The user’s email.
__
first_name|string
The user’s first name.
__
last_name|string
The user’s last name.
__
user_url|string
The user URL.
__
user_nicename|string
The URL-friendly user name.
__
display_name|string
The user’s display name. Default is the user’s username.
__
nickname|string
The user’s nickname. Default is the user’s username.
__
description|string
The user’s biographical description.
__
rich_editing|bool
Whether to enable the rich editor for the user.
__
syntax_highlighting|bool
Whether to enable the rich code editor for the user.
__
comment_shortcuts|bool
Whether to enable comment moderation keyboard shortcuts for the user.
__
admin_color|string
Admin color scheme for the user.
__
use_ssl|bool
Whether the user should always access the admin over HTTPS.
__
show_admin_bar_front|bool
Whether to display the Admin Bar for the user on the site’s front end.
__
locale|string
User’s locale.
var myUser = new UniWP.User();
var settings = new UserParameters{
email = "newemail@pipppo.com",
show_admin_bar_front = false,
first_name = "Pippo2"
}
_ = myUser.Update(10, settings)
.Done((WPReply reply) =>
{
if (reply.isOK) Debug.Log("Updated user ID: " + reply.data);
})
.Error((WPReply reply) =>
{
Debug.LogError(reply.error);
})
.Run()