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.
becomes myemail 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?
You can use something like this in your functions.php. The woocommerce_new_customer_username filter could be used to change the generated username. If you just return the customer email as the username, it will be used instead of the generated one (in your case the name before @).
function my_new_customer_username( $username, $email, $new_user_args, $suffix ) {
return $email;
}
add_filter( 'woocommerce_new_customer_username', 'my_new_customer_username', 10, 4 );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With