Skip to content

Instantly share code, notes, and snippets.

@jpmarchand
Created January 15, 2016 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpmarchand/63c5092a034d69d3d582 to your computer and use it in GitHub Desktop.
Save jpmarchand/63c5092a034d69d3d582 to your computer and use it in GitHub Desktop.
Disable password reset option in WordPress. Source: https://wpchannel.com/desactiver-remise-a-zero-mot-passe-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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment