Last active
November 12, 2015 19:16
-
-
Save jacobwise/48b0d6ae4ff948c541b1 to your computer and use it in GitHub Desktop.
Override user_login in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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