With code below, I try to update the email address of a user. The $_POST is correct, but the data is not saved into wp_users table.

$user_id = $_POST['ID']; // correct ID
wp_update_user( $user_id, 'user_email', $_POST['user_email']); // correct email address

Also tried this with success:

wp_update_user( array( $user_id, 'user_email', $_POST['user_email']) );         

What is wrong with this update?

1 Answer 1


The function needs an array with the parameters. See The Codex. Also, you map the parameter with the value: ex. 'user_email' => $_POST['user_email'].

In your example, the code should look like this:

    $user_id = (int) $_POST[ 'ID' ];
    wp_update_user( array(
        'ID' => $user_id,
        'user_email' => $_POST[ 'user_email' ]
   ) );

Also, the important hint: you should validate the data. Especially the data from the $_POST array. Maybe you're doing this, and it is not in your example source.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.