Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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 Juliobox (boiteaweb.fr)
* Author URI: http://valendesigns.com
*/
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
You can’t perform that action at this time.