Patrick Klug Patrick Klug - 1 month ago 14
PHP Question

Set full email address as username when registering through WooCommerce

WooCommerce under Settings/Account has an option named

Automatically generate username from customer email

but the username it generates is not the full email address.

as a username.

What method would I need to hook into to override the user generation so that the
full email is set as the username?


Simply use the hook pre_user_login

add_filter( 'pre_user_login' , 'wpso_same_user_email' );

function wpso_same_user_email( $user_login ) {

    if( isset($_POST['billing_email'] ) ) {
        $user_login = $_POST['billing_email'];
    if( isset($_POST['email'] ) ) {
        $user_login = $_POST['email'];
    return $user_login;