Skip to content

Instantly share code, notes, and snippets.

@mattboon
Created November 9, 2012 11:21
Show Gist options
  • Save mattboon/4045215 to your computer and use it in GitHub Desktop.
Save mattboon/4045215 to your computer and use it in GitHub Desktop.
Update WP user_login via SQL
<?php
// Force update our username (user_login)
global $wpdb;
$tablename = $wpdb->prefix . "users";
// method 1
//$sql = $wpdb->prepare("UPDATE %s SET user_login=%s WHERE ID=%d", $tablename, $user_email, $user_id);
//$wpdb->query($sql);
// method 2
$wpdb->update( $tablename, array( 'user_login' => $user_email ), array( 'ID' => $user_id ) );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment