Having an issue with getting the Lost you password text removed from my live site. For some reason after exhaustively checking almost everything (I guess I must have missed something) the text is still displaying. I put it in a child theme and tested that the child theme is bring read and it is. Very weird. Changed PHP versions etc., everything up to date, still displays. BUT on my local and live test sites it is being removed as desired. Any help would be appreciated as to what may be causing the issue.

function remove_lostpassword_text ( $text ) {
         if ($text == 'Lost your password?'){$text = '';} 
            return $text; 
    add_filter( 'gettext', 'remove_lostpassword_text' ); 
  • 1
    Can you try clearing the cache on your production site? Commented Apr 16, 2019 at 16:12
  • Your code has no errors. Clear site cache and it should work, Commented Apr 16, 2019 at 16:15
  • I haven't researched this desired effect to see about other solutions, but is this really good for performance? That code will run for every string that is set up for translations; i.e. almost all text in WordPress.
    – tmdesigned
    Commented Apr 16, 2019 at 16:17
  • Found the issue. Wordfence has an option to not display the user name when a password is incorrect. After un-checking that option, it works fine now, just took me a while to figure it out!
    – RJS77
    Commented Apr 16, 2019 at 19:09

1 Answer 1


You can use something like this code in your functions.php (this is what I use on one of my sites):

// Modifies the error message when login is done incorrectly, in THIS case removes the 'forgot password' link in the error message by changing the text
function login_error_override() {
     return '<center><strong>Oooooh.....<em>SO</em> close, but<br />....no soup for you!</strong><br />Those are the incorrect login details.<br />Please contact the Site Admin via our Contact Page for help.</center>';
add_filter('login_errors', 'login_error_override');

// Removes the lost password LINK from login form page and replaces with new text
function remove_lostpassword_text ( $text ) {
         if ($text == 'Lost your password?'){$text = 'If you\'ve forgotten your password, please contact the Site Admin via our Contact Page, thanks!';}
                return $text;
add_filter( 'gettext', 'remove_lostpassword_text' );

// Changes lost password URL to send clickers to our Contact page
add_filter( 'lostpassword_url',  'wdm_lostpassword_url', 10, 0 );
function wdm_lostpassword_url() {
    return site_url('/contact/');

// Redirects user back to login form instead of following lost password action
function disable_lost_password() {
    if (isset( $_GET['action'] )){
        if ( in_array( $_GET['action'], array('lostpassword', 'retrievepassword') ) ) {
            wp_redirect( wp_login_url(), 301 );
add_action( "login_init", "disable_lost_password" );

This ALSO removes the username from the error message, so that hackers don't know if they've guessed a valid username or not, it's a small thing but helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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