Disabled for username
-
Hi, I’m looking for simple code to disabled re-set password request for only 1 username, but i cannot find anywhere exactly code. Can you help archive this code? I used your plugin and it work as i wanted. But my web is too much plugin, i want to less as less plugin can be.
The username i wanted to disabled password request is “jamesadmin”. I found the bellow code, but it did not work correct.
Hope to hear from you!
=====================================================================================
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 ) && $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();
- The topic ‘Disabled for username’ is closed to new replies.