WordPress.org

Support

Support » Plugins and Hacks » [Plugin: SimpleModal Login] How to set Username to Email

[Plugin: SimpleModal Login] How to set Username to Email

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Eric Martin

    @emartin24

    The easiest way to do this might be to add the following code to your theme’s functions.php file:

    function mytheme_login_form($form) {
    	return str_replace('Username', 'Email', $form);
    }
    add_filter('simplemodal_login_form', 'mytheme_login_form');
    
    function mytheme_authenticate_username_password($user, $username, $password) {
    	$user = get_user_by_email($username);
    	if ($user) {
    		$username = $user->user_login;
    	}
    
    	return wp_authenticate_username_password(null, $username, $password);
    }
    remove_filter('authenticate', 'wp_authenticate_username_password', 20, 3);
    add_filter('authenticate', 'mytheme_authenticate_username_password', 20, 3);

    The code above will change Username to Email and then use the email to try and retrieve the user.

    This doesn’t include email validation and your client-side messages may still say username instead of email…but it’s a start.

    Many many thanks for the help. I’ll go see what I can do.

    This is great, but it doesn’t remove the UserName field from ‘Registration’. How can it me removed there as well?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: SimpleModal Login] How to set Username to Email’ is closed to new replies.