1

I am wanting to change the text "Get New Password" to "Send It" on the lost password page. The following code is what I have in my functions.php file, but it is not changing the default "Get New Password" text to "Send It' when I reload and hard-refresh the ./wp-login.php?action=lostpassword page of WordPress.

add_action( 'lostpassword_form ', 'wpse17711_lostpassword_form' );
function wpse17711_lostpassword_form()
{
add_filter( 'gettext', 'wpse17711_gettext' );
}

function wpse17711_gettext( $translation, $text )
{
if ( 'Get New Password' == $text ) {
    return 'Send It';
}
return $translation;
}

I can add numbers to the end of the add filter and it still does not change the default text:

add_filter( 'gettext', 'wpse17711_gettext', 10, 1 );

add_filter( 'gettext', 'wpse17711_gettext', 10, 2 );

add_filter( 'gettext', 'wpse17711_gettext', 9 );

What's wrong?

Update

As per Jack and Greg here is my final code:

add_action( 'lostpassword_form', 'wpse17711_lostpassword_form' );
function wpse17711_lostpassword_form()
{
add_filter( 'gettext', 'wpse17711_gettext' );
}

function wpse17711_gettext( $translation, $text )
{
if ( 'Get New Password' == $translation ) {
    return 'Send It';
}
return $translation;
}
  • You should use if ( 'Get New Password' == $translation ) { ... } instead. – Jack Johansson Jan 16 '18 at 2:22
  • As Jack said you should use $translation not $text in the if statement, and you have a space at the end of 'lostpassword_form ' make sure to delete that space inside quotes. – Greg36 Jan 16 '18 at 2:46
  • And, I knew I had to pay close attention to those extremely powerful tiny details and yet I and my relative still missed it. Thanks for the better eye, Greg36. That made it change "Get New Password" to "Send It" on the lost password page and with $text. However, Jack Johansson, I went ahead and changed $text to $translation as you have advised and updated my other function code (text change on the login page) to reflect the same change, too. I sincerely appreciate you both. – Bari Jan 16 '18 at 3:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.