{"id":41740,"date":"2025-10-07T04:17:50","date_gmt":"2025-10-07T01:17:50","guid":{"rendered":"https:\/\/coma.lv\/2025\/10\/07\/how-to-remove-password-recovery-and-password-change-from-wordpress\/"},"modified":"2025-10-07T04:17:50","modified_gmt":"2025-10-07T01:17:50","slug":"how-to-remove-password-recovery-and-password-change-from-wordpress","status":"publish","type":"post","link":"https:\/\/coma.lv\/en\/2025\/10\/07\/how-to-remove-password-recovery-and-password-change-from-wordpress\/","title":{"rendered":"How to Remove Password Recovery and Password Change from WordPress"},"content":{"rendered":"\n<h2 style=\"text-align: left;\">Why Remove Password Recovery or Password Change in WordPress<\/h2>\n<p style=\"text-align: left;\">If you have enabled registration on your site, the password recovery option lets people recover lost passwords. However, in some cases you may want to remove this option for certain users. For example, if you created a temporary account for someone, or if you created a demo site that users can log in to with a demo username and password. The simplest way in this case is just to remove the password recovery link. However, some users may still have the address of the password recovery form.<\/p>\n<h2 style=\"text-align: left;\">Method One: Remove the Password Recovery Option with a Plugin<\/h2>\n<p style=\"text-align: left;\">The plugin method is easier and more convenient. It lets you disable password recovery for all users. You need to install and activate the Reset Password Removed plugin.<\/p>\n<p style=\"text-align: left;\"><strong data-start=\"504\" data-end=\"519\">Note:<\/strong> Reset Password Removed disables password recovery for all users, including administrators.<\/p>\n<p style=\"text-align: left;\" data-start=\"1147\" data-end=\"1184\">After activation, the plugin automatically removes the \u201cLost your password?\u201d link and blocks the ability to recover a password for all users.<\/p>\n<h2 style=\"text-align: left;\">Method Two: Remove the Password Recovery Function in WordPress Manually<\/h2>\n<p style=\"text-align: left;\" data-start=\"1205\" data-end=\"1386\">If you prefer not to install additional plugins, or want to disable password recovery selectively for certain users, you can use custom code. To do this, open any text editor and create a file, for example <code data-start=\"646\" data-end=\"674\">disable-password-reset.php<\/code>. Paste one of the code options below into it.<\/p>\n<h3 style=\"text-align: left;\" data-start=\"1394\" data-end=\"1431\">Disabling for All Users<\/h3>\n<p style=\"text-align: left;\" data-start=\"709\" data-end=\"789\"><strong data-start=\"709\" data-end=\"789\">Option 1: block with a redirect and removal of the \u201cLost your password?\u201d link<\/strong><\/p>\n<p style=\"text-align: left;\">The following code completely blocks password recovery for all users, removes the \u201cLost your password?\u201d link on the login page and redirects anyone who tries to open the standard password reset page back to the login page:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&amp;lt;?php\r\nadd_filter( &amp;#039;allow_password_reset&amp;#039;, &amp;#039;__return_false&amp;#039; );\r\nadd_action( &amp;#039;login_init&amp;#039;, function() {\r\n    if ( isset( $_GET&#x5B;&amp;#039;action&amp;#039;] ) &amp;amp;&amp;amp; in_array( $_GET&#x5B;&amp;#039;action&amp;#039;], &#x5B;&amp;#039;lostpassword&amp;#039;, &amp;#039;retrievepassword&amp;#039;] ) ) {\r\n        wp_redirect( wp_login_url(), 301 ); \/\/ \u041f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0441\u0435\u0445 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0432\u0445\u043e\u0434\u0430\r\n        exit;\r\n    }\r\n});\r\nadd_filter( &amp;#039;gettext&amp;#039;, function( $text ) {\r\n    return ( $text === &amp;#039;Lost your password?&amp;#039; ) ? &amp;#039;&amp;#039; : $text;\r\n});\r\n?&amp;gt;\r\n<\/pre>\n<p style=\"text-align: left;\" data-start=\"1649\" data-end=\"1735\"><strong data-start=\"1649\" data-end=\"1735\">Option 2: block while keeping recovery available to administrators<\/strong><\/p>\n<p style=\"text-align: left;\" data-start=\"1649\" data-end=\"1735\">Another code snippet also completely blocks password recovery for all users and removes the \u201cLost your password?\u201d link on the login page. Administrators will be able to recover passwords through the admin panel, while for ordinary users recovery is completely unavailable:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&amp;lt;?php\r\nclass Password_Reset_Removed {\r\n    function __construct() {\r\n        add_filter(&amp;#039;show_password_fields&amp;#039;, array($this, &amp;#039;disable&amp;#039;));\r\n        add_filter(&amp;#039;allow_password_reset&amp;#039;, array($this, &amp;#039;disable&amp;#039;));\r\n        add_filter(&amp;#039;gettext&amp;#039;, array($this, &amp;#039;remove&amp;#039;));\r\n    }\r\n\r\n    function disable() {\r\n        $userdata = wp_get_current_user();\r\n        $user = new WP_User($userdata-&amp;gt;ID);\r\n        if ( ! empty( $user-&amp;gt;roles ) &amp;amp;&amp;amp; is_array( $user-&amp;gt;roles ) &amp;amp;&amp;amp; $user-&amp;gt;roles&#x5B;0] == &amp;#039;administrator&amp;#039; ) {\r\n            return true; \/\/ \u0410\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0430\u0434\u043c\u0438\u043d\u043f\u0430\u043d\u0435\u043b\u044c\r\n        }\r\n        return false; \/\/ \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442\r\n    }\r\n\r\n    function remove($text) {\r\n        return str_replace(array(&amp;#039;Lost your password?&amp;#039;, &amp;#039;Lost your password&amp;#039;), &amp;#039;&amp;#039;, trim($text, &amp;#039;?&amp;#039;));\r\n    }\r\n}\r\n\r\n$pass_reset_removed = new Password_Reset_Removed();\r\n?&amp;gt;\r\n<\/pre>\n<h3 style=\"text-align: left;\" data-start=\"2423\" data-end=\"2478\">Disabling for Specific Roles or Users<\/h3>\n<p style=\"text-align: left;\" data-start=\"3575\" data-end=\"3901\">If you need to block password recovery only for specific roles or individual users, use code that checks roles or user IDs:<\/p>\n<p style=\"text-align: left;\" data-start=\"3903\" data-end=\"3949\"><strong data-start=\"3903\" data-end=\"3949\">Blocking for everyone except administrators:<\/strong><\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&amp;lt;?php\r\nadd_filter(&amp;#039;allow_password_reset&amp;#039;, function($allow, $user_id) {\r\n    $user = get_userdata($user_id);\r\n    if (in_array(&amp;#039;administrator&amp;#039;, $user-&amp;gt;roles)) return true; \/\/ \u0410\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u044b \u043c\u043e\u0433\u0443\u0442 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c\r\n    return false; \/\/ \u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442\r\n}, 10, 2);\r\n?&amp;gt;\r\n<\/pre>\n<p style=\"text-align: left;\" data-start=\"4244\" data-end=\"4294\"><strong data-start=\"4244\" data-end=\"4294\">Blocking for specific users by ID:<\/strong><\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&amp;lt;?php\r\nadd_filter(&amp;#039;allow_password_reset&amp;#039;, function($allow, $user_id) {\r\n    $blocked_users = &#x5B;3, 7, 15]; \/\/ ID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043e\r\n    if (in_array($user_id, $blocked_users)) return false;\r\n    return true; \/\/ \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c\r\n}, 10, 2);\r\n?&amp;gt;\r\n<\/pre>\n<p style=\"text-align: left;\" data-start=\"2887\" data-end=\"3030\">Save your file. Then connect to your site via <a href=\"https:\/\/coma.lv\/en\/2024\/08\/26\/what-is-ftp\/\" target=\"_blank\" rel=\"noopener\">FTP<\/a> and go to the <strong data-start=\"3005\" data-end=\"3027\">wp-content\/plugins<\/strong> folder.<\/p>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2016\/11\/ftpplugindir-1.jpg\" alt=\"WordPress\" title=\"\"><\/p>\n<p style=\"text-align: left;\" data-start=\"3032\" data-end=\"3222\">Upload the file you created to this folder. Now go to the admin area&#8217;s <strong data-start=\"3112\" data-end=\"3123\">Plugins<\/strong> page, where you will see the new <strong data-start=\"3153\" data-end=\"3179\">Disable Password Reset<\/strong> plugin in the list of <a href=\"https:\/\/coma.lv\/en\/2024\/08\/21\/how-to-install-a-plugin-in-wordpress-a-step-by-step-guide-for-beginners\/\" target=\"_blank\" rel=\"noopener\">installed<\/a> plugins. Activate it.<\/p>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\"aligncenter\" style=\"margin-top: 0px; margin-bottom: 0px;\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2016\/11\/activateplugin-1.jpg\" alt=\"WordPress\" title=\"\"><\/p>\n<p style=\"text-align: left;\" data-start=\"3224\" data-end=\"3489\">After activation, password recovery will be disabled according to the chosen option: completely for all users, only for ordinary users, or for selected roles and specific users.<\/p>\n<hr \/>\n<p style=\"text-align: left;\"><em>Our specialization is WordPress website development and maintenance. Contact us for a free consultation \u2014 <a href=\"mailto:vadim@coma.lv\">vadim@coma.lv<\/a>, <a href=\"tel:+37129394520\">+371 29394520<\/a><\/em><\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>Why Remove Password Recovery or Password Change in WordPress If you have enabled registration on your site, the password recovery option lets people recover lost passwords. However, in some cases you may want to remove this option for certain users. For example, if you created a temporary account for someone, or if you created a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":37614,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1225,1406],"tags":[],"class_list":["post-41740","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","category-for-beginners"],"_links":{"self":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/comments?post=41740"}],"version-history":[{"count":0,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41740\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media\/37614"}],"wp:attachment":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media?parent=41740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/categories?post=41740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/tags?post=41740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}