2

How can you edit the labels of the wp-login.php form?

I am using emails for logins, so I need to change username to email.

The answer here seems to be out of date, or just doesn't work with SSL or something: Function to change a label (Username) in a core WordPress File (wp-includes/general-template.php)

I tried this in my functions file, but it didn't work:

function wpse60605_change_username_label( $defaults ) {
    $defaults['label_username'] = __( 'Email' );
    return $defaults;
}
add_filter( 'login_form_defaults', 'wpse60605_change_username_label' );
2

Found an answer on stackoverflow shortly after posting this:

https://stackoverflow.com/questions/12825865/change-wordpresss-login-label-username

Uses the gettext filter instead of any wp functions

2

Found this here: https://wordpress.org/support/topic/how-to-change-the-text-labels-in-userpass-box-on-login-page/

The other answer here didn't work for me, but this one did.

Just in case this helps anyone.

add_filter( 'gettext', 'register_text' );
add_filter( 'ngettext', 'register_text' );
function register_text( $translated ) {
    $translated = str_ireplace(
        'Username or Email Address',
        'Your Custom Text',
        $translated
    );
    return $translated;
}
  • Like for Carole, the above (chosen answer) did not work for me. But, this worked! (WordPress version 4.7.x). – seveninstl Nov 7 '17 at 5:36
0

Try this

add_filter(  'gettext',  'register_text'  );
add_filter(  'ngettext',  'register_text'  );
function register_text( $translating ) {
     $translated = str_ireplace(  'Username or Email Address',  'Your Custom Text',  $translating );
     return $translated;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.