Codex tools: Log in
Languages: English • 한국어 • (Add your language)
Contents |
This function updates a single user in the database. This update can contain multiple pieces of user metadata as an array.
To update a single piece of user metadata, use update_user_meta() instead.
To create a new user, use wp_insert_user() instead.
Note: If current user's password is being updated, then the cookies will be cleared!
If $userdata does not contain an 'ID' key, then a new user will be created and the new user's ID will be returned. NOTE: This seems to no longer be true: http://core.trac.wordpress.org/ticket/17009#comment:7
<?php wp_update_user( $userdata ) ?>
Below is an example showing how to update a user's website profile field
<?php
$user_id = 1;
$website = 'http://wordpress.org';
wp_update_user( array ( 'ID' => $user_id, 'user_url' => $website ) ) ;
?>
Please note that we cannot change the usernames through this function, in fact the usernames cannot be changed from the admin dashboard as well since WordPress does not allow the usernames to be updated.
| Field Name | Description | Associated Filter |
|---|---|---|
| ID | An integer that will be used for updating an existing user. | (none) |
| user_pass | A string that contains the plain text password for the user. | pre_user_pass |
| user_login | A string that contains the user's username for logging in. | pre_user_login |
| user_nicename | A string that contains a URL-friendly name for the user. The default is the user's username. | pre_user_nicename |
| user_url | A string containing the user's URL for the user's web site. | pre_user_url |
| user_email | A string containing the user's email address. | pre_user_email |
| display_name | A string that will be shown on the site. Defaults to user's username. It is likely that you will want to change this, for both appearance and security through obscurity (that is if you dont use and delete the default admin user). | pre_user_display_name |
| nickname | The user's nickname, defaults to the user's username. | pre_user_nickname |
| first_name | The user's first name. | pre_user_first_name |
| last_name | The user's last name. | pre_user_last_name |
| description | A string containing content about the user. | pre_user_description |
| rich_editing | A string for whether to enable the rich editor or not. False if not empty. | (none) |
| user_registered | The date the user registered. Format is Y-m-d H:i:s. | (none) |
| role | A string used to set the user's role. | (none) |
| jabber | User's Jabber account. | (none) |
| aim | User's AOL IM account. | (none) |
| yim | User's Yahoo IM account. | (none) |
| show_admin_bar_front | Show the WP admin bar on the front-end. | (none) |
Remember, user_pass should be the plain text password as it will be automatically hashed by WordPress.
wp_update_user() is located in wp-includes/user.php.