Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hiding Admin Accounts


  • andyjay83
    Participant

    @andyjay83

    Wordpress 4.9.5, BuddyPress 2.9.4, BuddyBoss Theme, http://www.torus.drumsbygenre.com

    I am trying to hide all admin accounts from all BuddyPress touch points using this code found on the BuddyDev website:

    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;
    }

    This code seemed to have worked for a lot of people but isn’t currently working for me. I tried putting it into my child theme’s functions.php and also tried making a bp-custom.php file in my wp-content/plugins directory and that didn’t work either. I even refreshed cache and cookies after each of these attempts. Still nothing.

    I’m not advanced when it comes to this stuff. I know that I must be doing something wrong. Any help or guidance would be greatly appreciated.

  • You must be logged in to reply to this topic.
Skip to toolbar