0

Is it possible to make WordPress user name the Email Address? when user register in my site.

So unername could be hidden or not required and is replaced with email address.

I use WP User Frontend plugin.

I know there are plugins that can allow users to use their email as the log in, but they still have to enter the username when they register. I want to try and do away with the username.

0

You could use the user_register-hook, to replace the username with the mail-address right after the account has been created.

It could be something like this (untested) in your functions.php:

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

function wpse216787_mail_as_username( $user_id ) {
    $email = get_the_author_meta( 'user_email', $user_id );
    update_user_meta($user_id, 'user_login', $email );
}
  • Hi @flomei ,, Sory its not work , its not set username like email – Wp Gfx Feb 5 '16 at 10:41
  • Any error messages? – flomei Feb 5 '16 at 10:51
  • i test to register in my site and go to phpmyadmin to show user_login, its not like user_email – Wp Gfx Feb 5 '16 at 10:58
  • and i try to login with email, but its say the username not correct – Wp Gfx Feb 5 '16 at 10:59
  • Well, then debug the code and check where the problem is. – flomei Feb 5 '16 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.