Hi folks,
It appears that wp_update_user cannot update 'user_login'. Explanation is here: http://radiok.info/blog/wp_update_user-and-user_login/. I'm not sure if the solution is to remove the variable from the list of possible keys in $userdata or to leave a note next to it explaining the issue, but something should be done on this page.
Err, just noticed the note "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." If this is the case then what reason is there for having user_login in the chart?
MarcGuay 16:52, 31 January 2013 (UTC)
I used the example script to change the user's email. I want to catch when my script tries to change the user_email when it already exists. When I enter a duplicate email, the function 'wp_update_user' does not change the user_email (as it shouldn't). However, the following test ( if ( is_wp_error( $user_id ) ) ) to see if it failed or not, does not work. The test always passes. Even when wp_update_user does not add the new email. Is there a test i can do without having to read the record again and compare old user_email to new?
$user_id = 1;
$user_id = wp_update_user( array( 'ID' => $user_id, 'user_email' => $duplicate_email) );
if ( is_wp_error( $user_id ) ) { // There was an error, probably that user doesn't exist. } else { // Success! }