WordPress Snippets at WPcustoms

Disable password reset

This function removes the password reset / change field in the user’s profile dashboard. Only admins get the password reset input field. A good way to prevent password changes – however you should let your users know that they need to get in contact with an admin to change their user password. The action=lostpassword url is also blocked and returns a message that you are not allowed to reset your password.

 * Snippet Name: Disable password reset
 * Snippet URL: http://www.wpcustoms.net/snippets/disable-password-reset/
 // hide the password reset input field in the user's profile page
function wpc_disable_password_reset()
    if ( is_admin() ) {
      $userdata = wp_get_current_user();
      $user = new WP_User($userdata->ID);
      if ( !empty ( $user->roles ) && is_array( $user->roles ) && $user->roles[0] == 'administrator' )
        return true;
    return false;
 add_filter( 'show_password_fields', 'wpc_disable_password_reset' );

// this function disables the password reset form.
function wpc_disable_reset_lost_password() 
   return false;
 add_filter( 'allow_password_reset', 'wpc_disable_reset_lost_password');