Below is the code to disable password reset option in WordPress.
<?php | |
/* | |
* Plugin Name: Password Reset Removed | |
* Description: Removes the ability for non-admin users to change/reset their passwords | |
* Version: 1.1 | |
* Author: Derek Herman. Modified by Juliob Potier. | |
*/ | |
add_filter('show_password_fields', 'baw_prr_i_am_admin'); | |
add_filter('allow_password_reset', 'baw_prr_i_am_admin'); | |
add_filter('gettext', 'baw_prr_remove_me'); | |
function baw_prr_i_am_admin() { | |
return is_admin() && current_user_can('administrator'); | |
} | |
function baw_prr_remove_me($text) { | |
return str_replace(array('Lost your password?', 'Lost your password'), '', trim($text, '?')); | |
} | |
function baw_prr_no_password_change($dummy1, $dummy2, $user) { | |
if (!baw_prr_i_am_admin()) unset($user->user_pass); | |
} | |
add_action('user_profile_update_errors', 'baw_prr_no_password_change', 10, 3); |