Skip Navigation

[Resolved] Editing login form labels

This thread is resolved. Here is a description of the problem and solution.

Problem:
The customer wants to modify the labels of the login form so that users can log in with their email only, not their username. They can add the login form via shortcode but need to customize the form labels.
Solution:
We informed the customer that customizing the login form labels requires adding custom code to the theme/child theme's function.php file. We initially provided the following code snippet:

add_filter('gettext', 'user_label_change', 20, 3);
function user_label_change($translated_text, $text, $domain) {
    if ($text === 'Username or Email' && $domain == 'default') {
        $translated_text = 'Email';
    }
    return $translated_text;
}

The customer later managed to achieve their goal with a different function:

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

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 1 reply, has 2 voices.

Last updated by Mateus Getulio 2 months, 1 week ago.

Assisted by: Mateus Getulio.

Author
Posts
#2697382

Hello,

I can add the login form via text and fields which adds a shortcode.
But How can I edit the labels of the form itself? (I need users to login with email only not username)

Thanks,

Jacques

#2697448

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello Jacques,

I'm afraid it is only possible to customize it by using some custom code.

Please try to add the following code to your theme/child theme's function.php file:

add_filter( 'gettext', 'user_label_change', 20, 3 );
function user_label_change( $translated_text, $text, $domain )
{
    if ($text === 'Username or Email' &&  $domain == 'default'){
            $translated_text = 'Email';
    }
    return $translated_text;
}

Thank you, please let us know.
Mateus

#2697821

Thanks,

i managed with adding a function but for some reason your code didnt work in my case but the below did:

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

JacquesF783 confirmed that the issue was resolved on 2024-05-15 08:43:33.
This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.