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).
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!
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,
);
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;}
Nice works, thanks for sharing
Worked, thanks.
fake
Same here…doesn’t work
Doesn’t work… I added it to my theme’s functions.php file and the link is still there.