I use a third party plugin that adds Social Login option to my blog. It works very well, but I dislike that when users choose to login by their social accounts the user login names (user_login in database) are saved in this format - "First-Second", so the first letter of the each part are capitals. My own user_login will be "Iurie-Malai", but I would like "iurie-malai".

I know that WordPress usernames are case-insensitive, but I want that user logins to be only in lowercase. How can I do this?

1 Answer 1


You can hook into the user_register action hook and lower case the strings manually, by using the wp_update_user function. Here's a quick example:

add_action( 'user_register', 'callback_function', 10, 1 );

function callback_function( $user_id ) {
    // Get the user by their ID
    $user = get_user_by( 'id', $user_id );
    // Update their user_login
            'ID'         => $user_id, 
            'user_login' => strtolower( $user->user_login ) 

Using the pre_user_login filter

You can use the above filter to filter the user's login before its added to the database, as follows:

add_filter( 'pre_user_login', 'callback_function' );
function callback_function( $login ) {
    return strtolower( $login );
  • Thank you! I am not sure if my initial question was very clear, so I updated it. Your answer is about user meta, not about user_login, as I asked.
    – Yurié
    Nov 19, 2017 at 12:05
  • 1
    You're welcome. I've updated the answer.
    – Johansson
    Nov 19, 2017 at 12:28

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.