Created
January 16, 2011 04:57
-
-
Save anonymous/781573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Plugin Name: Password Reset Removed | |
* Description: Removes the ability for non admin users to change/reset their passwords. | |
* Version: 1.0 | |
* Author: Derek Herman | |
* Author URI: http://valendesigns.com | |
*/ | |
class Password_Reset_Removed | |
{ | |
function __construct() | |
{ | |
add_filter( 'show_password_fields', array( $this, 'disable' ) ); | |
add_filter( 'allow_password_reset', array( $this, 'disable' ) ); | |
add_filter( 'gettext', array( $this, 'remove' ) ); | |
} | |
function disable() | |
{ | |
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; | |
} | |
function remove($text) | |
{ | |
return str_replace( array('Lost your password?', 'Lost your password'), '', trim($text, '?') ); | |
} | |
} | |
$pass_reset_removed = new Password_Reset_Removed(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment