Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change WordPress's login label, "Username"

On the default WordPress login page, how do you change the label, "Username", to something else?

like image 915
Seed Avatar asked Nov 28 '22 00:11

Seed


2 Answers

I think this is a better alternative to the previous answer.

function login_function() {
    add_filter( 'gettext', 'username_change', 20, 3 );
    function username_change( $translated_text, $text, $domain ) 
    {
        if ($text === 'Username') 
        {
            $translated_text = 'customLoginName';
        }
        return $translated_text;
    }
}
add_action( 'login_head', 'login_function' );
like image 102
Seed Avatar answered Dec 24 '22 00:12

Seed


Simple & Short Solution

add_filter(  'gettext',  'register_text'  );
function register_text( $translating ) {
    $translated = str_ireplace(  'Username or Email Address',  'Your Custom Text',  $translating );
    return $translated;
}
like image 34
dev Avatar answered Dec 23 '22 23:12

dev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!