Codex

Function Reference/wp update user

Contents

Description

Update a user in the database.

It is possible to update a user's password by specifying the 'user_pass' value in the $userdata parameter array.

If $userdata does not contain an 'ID' key, then a new user will be created and the new user's ID will be returned.

If current user's password is being updated, then the cookies will be cleared.

Note: Use the wp_insert_user function to create a new user.

Usage

<?php wp_update_user$userdata ?>

Parameters

$userdata
(array) (required) An array of user data.
Default: None

Return Values

UserID (integer) 
The updated user's ID.

Examples

Below is an example showing how to update a user's Website profile field

<?php
require_once( ABSPATH . WPINC . '/registration.php');
$user_id = 1;
$website = 'http://wordpress.org';
wp_update_user( array ('ID' => $user_id, 'user_url' => $website) ) ;
?>

Notes

Change Log

Source File

wp_update_user() is located in wp-includes/user.php.

Related

See also index of Function Reference and index of Template Tags.