0

When a user uses the password reset functionality in WordPress, they are asked to enter their email and click confirm. After doing so, they get the message:

Check your email for the confirmation link, then visit the login page.

I wish to modify this message, and I have found the line of code where the message is written in the wp-login.php file:

if ( 'confirm' === $_GET['checkemail'] ) {
  $errors->add(
    'confirm',
    sprintf(
      /* translators: %s: Link to the login page. */
      __( 'Check your email for the confirmation link, then visit the <a href="%s">login page</a>.' ),
      wp_login_url()
    ),
    'message'
  );
}

Changing the message there works fine and all, but am I correct in assuming that it would be overwritten as soon as WordPress is updated? If so, my questions are:

  • Is it possible for me to modify this message with a function that I could put in my theme's functions.php file so that it won't be overwritten by future WP updates?

  • Can I also have a translation for my new message? If I edit the translation file in the /wp-content/languages folder, I assume it would also be overwritten by an update?

0

If there is no filter to change the content, the other option is to add a function hooked to gettext - for example:

/**
 * Change text strings
 *
 * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
 */
function wpse_382257_text_strings( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'Check your email for the confirmation link, then visit the login page.' :
            $translated_text = __( 'SOMETHING ELSE', 'text-domain' );
            break;
        
        case 'Another' :
            $translated_text = __( 'Whatever..', 'text-domain' );
            break;
    }
    return $translated_text;
}
add_filter( 'gettext', 'wpse_382257', 20, 3 );

ref: https://developer.wordpress.org/reference/hooks/gettext/

2
  • Thank you for the tip! This particular example doesn't seem to work for me, but I'll read up on the hook and see if I can figure it out. :) – Dalen Jan 29 at 9:08
  • It is a string compare - that's to say, it searches for an exact match, which is more reliable on short, simple strings - like case 'yes' or case 'no' - the longer the string, the more possible miss-matches.. – Q Studio Jan 29 at 11:39

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.