many users would to allow the registration in a wp site without an username, just only with an email.
This is a core problem, so the solution (a trick) is to replace username with email.
If wp requires an username and an email for the registration, we can get email value and put it in username value. In the registration form users will see two fields:
- your email
- repeat your email
This is a trick, because for wp the real fields will be: 1. username (as your email) 2. your email (as repeat your email)
But there is another problem: is the @ (at) an allowed character for username?
How can we do this?
Should we insert a code in functions.php file?.. something like this:
add_action( 'wp_core_validate_user_signup', 'custom_validate_user_signup' );
function custom_validate_user_signup($result)
{
unset($result['errors']->errors['user_name']);
if(!empty($result['user_email']) && empty($result['errors']->errors['user_email']))
{
$result['user_name'] = md5($result['user_email']);
$_POST['signup_username'] = $result['user_name'];
}
return $result;
}
Thank you in advance!