• Hi,

    I’d like to hide the username field all together for registration and login and just use email.

    Could you give me some pointers to accomplish this please? I obviously need to hide the username fields on your screen and then assign the value programmatically, however I haven’t been able to get this to work.

    Many thanks
    Guy

    http://wordpress.org/extend/plugins/simplemodal-login/

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

    (@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.

    Thread Starter gplatt

    (@gplatt)

    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.