X

How to Disable the Password Reset Feature in WordPress

Snippets by IsItWP

Wondering how to disable the password reset feature in WordPress? Adding this snippet to the functions.php file will disable the password reset feature from the login page. If a user tries to reset their password from the login page, then an error message will be shown: “Password reset is not allowed for this user”.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

function disable_password_reset() { 
              return false;
              }
add_filter ( 'allow_password_reset', 'disable_password_reset' );

If you want to remove the Lost your password? text from the login page, just go ahead and add this snippet to your functions.php file, instead of the above snippet.

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

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: Best WordPress Page Builders (Compared).

Comments   Leave a Reply

  1. If you use this code keep in mind that the specific text can vary because of language. It does not remove the link if the text is not exactly like in the code.

    Copy paste the exact text in between ‘your language specific text’

    if ($text == ‘Lost your password?’){$text = ”;}

    It works for sure!

  2. Aysad Kozanoglu January 9, 2020 at 9:59 pm

    edit wp-login.php and change the parameters for $default_actions to disable lostpassword and resetpass

    $default_actions = array(
    ‘confirm_admin_email’,
    ‘postpass’,
    ‘logout’,
    //’lostpassword’,
    ‘retrievepassword’,
    //’resetpass’,
    ‘rp’,
    ‘register’,
    ‘login’,
    ‘confirmaction’,
    WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED,
    );

  3. You can hide this by adding in some CSS in wp-admin.css add in the code below to /public_html/wp_admin/css/wp-admin.css:

    #login_error {display: none;}

  4. Nice works, thanks for sharing

  5. Worked, thanks.

  6. fake

  7. Same here…doesn’t work

  8. Doesn’t work… I added it to my theme’s functions.php file and the link is still there.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!