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;
}