Change field label text on Woocommerce login form
Your code will work if you add return $translated_text;
at the end in your function as in any filter hook it's mandatory to return the filtered value.
To restrict this function to my account registering form you will use the following conditions:
add_filter( 'gettext', 'wppb_change_text_login', 10, 3 );function wppb_change_text_login( $translated_text, $text, $domain ) { // Only on my account registering form if ( ! is_user_logged_in() && is_account_page() ) { $original_text = 'Username or email address'; if ( $text === $original_text ) $translated_text = esc_html__('Your registered email address', $domain ); } return $translated_text;}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
For rename Label "Username or email address" to "Your registered email address" Please add following function into your theme function.php
add_filter( 'gettext', 'register_text' );add_filter( 'ngettext', 'register_text' );function register_text( $translated ) { $translated = str_ireplace( 'Username or Email Address', 'Your registered email address', $translated ); return $translated;}
I have tested the above function with storefront theme and its working for me please check the screenshot https://prnt.sc/m25hwz