Skip to:
Content
Pages
Categories
Search
Top
Bottom

Help removing Admins from the Member list


  • tackleb0x
    Participant

    @tackleb0x

    Hi,
    I am having a visual issue when removing Admins from displaying in the Member list. I have successfully removed the Admins, however, it is not visually appealing. I have 4 subscribers and 2 admins. With the code I have in my functions.php page, I see the following on the Members page: Viewing 1 – 4 of 4 active members. That is correct. However, right above that, it says the following: All Members 6. How do I change that count at the top to exclude the admins?

    Website: http://www.tacklebox.fish
    WP Version: 4.7.5
    BP Version: 2.8.2

    functions.php:
    /*
    * Removes all Admin roles from Member list.
    */

    add_filter( ‘bp_after_has_members_parse_args’, ‘buddydev_exclude_users_by_role’ );

    function buddydev_exclude_users_by_role( $args ) {
    //do not exclude in admin
    if( is_admin() && ! defined( ‘DOING_AJAX’ ) ) {
    return $args;
    }

    $excluded = isset( $args[‘exclude’] )? $args[‘exclude’] : array();

    if( !is_array( $excluded ) ) {
    $excluded = explode(‘,’, $excluded );
    }

    $role = ‘administrator’;//change to the role to be excluded
    $user_ids = get_users( array( ‘role’ => $role ,’fields’=>’ID’) );

    $excluded = array_merge( $excluded, $user_ids );

    $args[‘exclude’] = $excluded;

    return $args;
    }

    Please let me know if these is anything I can do to accomplish this, or if I am doing it incorrectly.

    Thanks in Advance!
    Buddy

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar