Change a user
wp_update_userUpdate an existing WordPress user account by changing only the email, first or last name, role, or password you provide, then return the updated user and ID.
Instructions
Update an existing user account: email, first and last name, role or password. Only the fields given change. Returns updated and id. Needs edit_users and the right to edit this user; a role change needs promote_users and the right to promote this user, takes only roles the account may assign (editable_roles) and, for an account that is neither a single-site administrator nor a super admin, cannot give rights the account lacks; demoting the last administrator is refused. A call that sets a role is refused (ab_mcp_busy) and changes nothing while another role change or user deletion runs through AlphaBridge; a call that loses that lock on the way (a renewed database connection) is refused too: noticed before the other fields are saved, it changes nothing, noticed after them, it leaves only the role unchanged, and the answer says which. These checks cover calls through AlphaBridge, not changes made in wp-admin at the same moment. When the password changes, WordPress e-mails a notice to the user's address; when the email changes, it e-mails the previous address, naming the new one (the filters send_password_change_email and send_email_change_email can switch these off). No undo point is recorded.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | User id, as wp_list_users or wp_get_user return it. | |
| role | No | New role slug; replaces the user's roles on this site. Empty or omitted: the role stays. | |
| No | New email address. | ||
| password | No | New password. Empty or omitted: the password stays. | |
| last_name | No | New last name; an empty string clears it. | |
| first_name | No | New first name; an empty string clears it. |