Yes, disable Order Attribution is a solution.
It should be a bug.
Thanks @aliwake
Thank you very much @jricketts4 and @greysouth , it works.
It is important for me because the default is now first-name and last name, the problem is last name often have two words with SPACE, so the username by default “firstname(dot)LAST(space)NAME”, I don’t want that space.
On Line 3 and 4, I changed billing_email to billing_phone so the username changed to be phone number. Thanks.
I curious with the function of [’email’] on Line 7 and 8. Could you give us the explanation about it? Do I need change it to [‘phone’]?
Thank you.
add_filter( ‘pre_user_login’, ‘wc_email_as_username’ );
function wc_email_as_username( $user_login ) {
if( isset($_POST[‘billing_email’] ) ) {
$user_login = $_POST[‘billing_email’];
}
if( isset($_POST[’email’] ) ) {
$user_login = $_POST[’email’];
}
return $user_login;
}