Skip to content

Instantly share code, notes, and snippets.

@jacobwise
Last active November 12, 2015 19:16
Show Gist options
  • Save jacobwise/48b0d6ae4ff948c541b1 to your computer and use it in GitHub Desktop.
Save jacobwise/48b0d6ae4ff948c541b1 to your computer and use it in GitHub Desktop.
Override user_login in WordPress
// Check if user_login already exists before we force update
if ( ! username_exists( $username ) ) {
// Force update user_login and user_nicename
$tablename = $wpdb->prefix . "users";
$wpdb->update( $tablename, // Table to Update ( prefix_users )
array(
'user_login' => $username, // Data to Update ( user_login )
'user_nicename' => $username // Data to Update ( user_nicename )
),
array( 'ID' => $user->ID ), // WHERE clause ( ID = $user->ID )
array(
'%s', // Data format ( string )
'%s' // Data format ( string )
),
array('%d') // Where Format ( int )
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment