Home / functions.php / Remove the lost your password? link
  • How to Remove the lost your password? link


    Yesterday I posted a snippet to disable the lost password feature in wordpress. This will add to that little snippet and remove the lost password text from the wordpress login page. This does not remove the link but just replaces the Lost your password? text with nothing effectively removing the link.

    ( click code to copy )

    wordpress snippet : PHP

    function remove_lostpassword_text ( $text ) {
    	 if ($text == 'Lost your password?'){$text = '';}
    		return $text;
    add_filter( 'gettext', 'remove_lostpassword_text' );

    ( WordPress codex functions, hooks, in this snippet. )

    gettext, add_filter,
  • And how to remove the lost pass text when you’re using WP in another language?

    • If you change the text on line 2. called “Lost your password?” to what is displayed in another language that should work. Let me know if this works if not ill do a little digging for you.

      • Funky2D

        Hi there,

        I’ve tried to change line 2 in french unfortunately didn’t work.
        if ($text == ‘Mot de passe oublié ?’ )
        Any idea ?


        • Funky2D

          This made it just in case : ($text == ‘Mot de passe oublié ?’)

  • Uwe Conrad

    Hi Kevin

    Tried this but after inserting the code into the functions.php file and reloading the login page it’s all gone. No background, no login form, nothing. Just white. No error message either. Do I really only have to copy your code and paste in? No special characters to place at the beginning or end?

    • the location in the functions.php file does not matter however you want to make sure you place it after the first < ? other then that should be fine. If you still have problem you could post the file on http://pastebin.com/ and post the link in the comments and I can take a look at the file.

  • Pgduke65

    Hi Kevin,
    I am unable to get this to work properly.  I am sure its me.  I am a noob to wordpress.  I added the code to the functions.php file and refreshed the login page an there was no change?  Any idea where I am going wrong?

    • Hi, no problem if you wanted to paste the contents of your functions.php wthin http://pastebin.com and then post the url it sends in a comments I can take a look for you.

  • Anonymous

    Thanks Kevin, simple & clever  method!

  • Tuan Vo

    Thank you Kevin. Great job.

  • Thank you so very much!! Exactly what i was looking for :)
    Just for notes, code should be pasted at functions.php like Kevin said.

  • Andrea Garza

    This is EXACTLY what just saved my sanity! Can’t thank you enough!

  • Mark

    Hi Kevin, this is awesome. Having looking hi and low for this. How do I disable the ‘back to site’ link?

  • Forum

    Hi Kevin,

    This code snippet is not working in my case. I need to get rid of the lost password link for my website. I have added the code to theme’s function.php. Still its not working. Is it due to some different plugin interference ?

    • Its hard to say if that is the case the only way to know would be disable all the plugins and see if things are working. Once things are working you can enable the plugins one by one to check and see what plugin caused the issue. This is a pretty simple snippet, so I would confirmed that you added this to the functions.php correctly.