Hi @lubomir3000,
1. Yes, i prefer the email login so i understand your preference but for me its just restricting a choice of the user.
2. Just to be clear, email only login is 100% not a workaround for that.
WP uses the username in many places, its not considered private in any way.
Its exposed in places such as post author links, and comment author links to name just two.
Even if a user had never posted anything on a site a “hacker” could simply loop through all user IDs to find the username with mysite.com/?author=x with x being the user id such as mysite.com/?author=1 which will bring them to the author page exposing the username.
Anyway, the code below will restrict the field to email only. You can use a plugin such as “code snippets” to add this or simply add it to your child theme functions.php file.
add_filter('uwp_validate_result','_my_email_only_login',10,2);
function _my_email_only_login($result,$type){
// check its a login we are validating, and there is not already and error
if( $type == 'login' && !is_wp_error( $result ) && isset($result['uwp_login_username']) ){
// if the username is not a email then throw an error
if( !is_email( $result['uwp_login_username'] ) ){
$errors = new WP_Error();
$incorrect_email_error_msg = apply_filters('uwp_incorrect_email_error_msg', __('<strong>Error</strong>: The email address isn’t correct.', 'userswp'));
$errors->add('invalid_email', $incorrect_email_error_msg);
return $errors;
}
}
return $result;
}
To change the input text the easiest way would be to use the plugin .mo/.po translations files to change the text “Username or Email” to “Email”.
If i can help further just let me know ??
Thanks,
Stiofan