Support » Plugin: Plainview Protect Passwords » Disabled for username

  • Resolved TheDream18

    (@oanhtran1804)


    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();

Viewing 1 replies (of 1 total)
  • Plugin Author edward_plainview

    (@edward_plainview)

    Well, I won’t be writing your code for you, but I’ll give you a clue on where to look.

    add_action( ‘allow_password_reset’, ‘hook_true_on_freedom’, 10, 2 );
    add_action( ‘show_password_fields’, ‘hook_true_on_freedom’, 10, 2 );

    This is in the plugin source code open for you to see.

Viewing 1 replies (of 1 total)
  • The topic ‘Disabled for username’ is closed to new replies.