Q:

Change field label text on Woocommerce login form

This Question is similar to Rename username label on woocommerce login page
I am trying to change the Label "Username or email address" to "Your registered email address"

I am trying to do this without modifying the form-login.php template file.
So far I tried the below code:
function wppb_change_text_login( $translated_text, $text ) {
    //Login page
    $original_text = 'Username or email address';
    $new_text = 'Your registered email address';
    if ( $text == $original_text ) {
        $translated_text = $new_text;
    }
}
add_filter( 'gettext', 'wppb_change_text_login', 30, 2 );

However, I understand that gettext is very resource intensive function and I was wondering what changes should I make to make these changes be restricted to my-account page.

A:

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.

