Skip to:
Content
Pages
Categories
Search
Top
Bottom

Feature request: Hide certain members


  • mlemberg
    Participant

    @mlemberg

    To me it seems odd, that site administrators are visible to other users. At my site I have two members named “Admin” and “Forum Admin”, Their roles goes without saying.

    But all my other members are regular users with regular names. Therefore it bothers me, that these two accounts show up in the members directory and the “Who’s online” widget.

    I would very much like the possibility to hide certain members from the directory, site wide activity and widgets, so that they can be sort of “silent watchers”.

    Any body else who’d like this feature

Viewing 20 replies - 1 through 20 (of 20 total)

  • Jens Wedin
    Participant

    @jedisthlm

    Also looking for a way to hide the admins. Anyony have a clue?

    Change the user_status value in the wp_users table for those users to something like 99 and they will be hidden. That’s one somewhat hacky way of hiding them in the frontend.


    Jens Wedin
    Participant

    @jedisthlm

    Thanks, that is ok for now!

    Ya. I too want solution for the same kind of problem. It was ok for now. Is there any way to do that through code??

    this is not 100% ok. somethimes it will display the member. Anyone know how to?

    My solution is to modify members-loop.php (I’m using template pack)

      <?php while ( bp_members() ) : bp_the_member();
      $exclude_ids = array(1,3); /* member ids to exclude from listing */
      if (!in_array(bp_get_member_user_id(), $exclude_ids)) {
      ?>

    `

      <?php while ( bp_members() ) : bp_the_member();
      $exclude_ids = array(1,3); /* member ids to exclude from listing */
      if (!in_array(bp_get_member_user_id(), $exclude_ids)) {
      ?>`

    Fee
    Participant

    @wdfee

    this should work for excluding all super admins:

    `

      <?php while ( bp_members() ) : bp_the_member();
      if( !in_array( bp_get_member_user_login(), get_super_admins() ) ) {
      ?>`

    Thanks, @acurran, I was looking for the code too and tried your suggestion but got an error:

    Parse error: syntax error, unexpected T_ENDWHILE in /home/domain/public_html/wp-content/plugins/buddypress/bp-themes/bp-default/members/members-loop.php on line 68

    on line 68 there is

    I don’t know how to get it right here. Does somebody know solution to this?


    G
    Participant

    @gnetworkau


    boydspace
    Participant

    @boydspace

    None of this works for me anymore. Has anyone else found some way to do this? (I am using the mos up to date settings as of 7/30/2013)


    philipstancil
    Participant

    @philipstancil

    Crazy that we both found this old thread within 12 hours of each other. I got it working with this code:

    // Remove admin from directory
    
    add_action('bp_ajax_querystring','bpdev_exclude_users',20,2);
    function bpdev_exclude_users($qs=false,$object=false){
     //list of users to exclude
     
     $excluded_user='1';//comma separated ids of users whom you want to exclude
     
     if($object!='members')//hide for members only
     return $qs;
     
     $args=wp_parse_args($qs);
     
     //check if we are listing friends?, do not exclude in this case
     if(!empty($args['user_id']))
     return $qs;
     
     if(!empty($args['exclude']))
     $args['exclude']=$args['exclude'].','.$excluded_user;
     else
     $args['exclude']=$excluded_user;
     
     $qs=build_query($args);
     
     return $qs;
     
    }
    
    //Remove admin from member count
    
    add_filter('bp_get_total_member_count','bpdev_members_correct_count');
    function bpdev_members_correct_count($count){
    $excluded_users_count=1; //change it to the number of users you want to exclude
    return $count-$excluded_users_count;
    }
    

    merosler
    Participant

    @merosler

    Hi Phillip,

    Which .php file did you add the above code to?

    thank you,
    Matt


    philipstancil
    Participant

    @philipstancil

    Hey Matt (merosler)!

    I added the code to my child theme’s functions.php file. If you aren’t using a child theme, you should be able to simply add it to your active theme’s functions.php file.

    Hope that helps!


    merosler
    Participant

    @merosler

    Hi Phillip,

    Where exactly did you add the code int the php file? I tried adding it to the very bottom of the file but that resulted in that code appearing as text at the top of my site.

    thank you,
    Matt


    bp-help
    Participant

    @bphelp

    @merosler
    If your adding php code I hope you have made a child theme as @philipstancil did because that is the proper way. I would never add custom code to a parent theme’s functions.php because if you update the theme then it may get overwritten. Anyway, make sure whenever you add code to functions.php it always needs to be between opening and closing php tags like this:

    
    <?php
    // Remove admin from directory
    
    add_action('bp_ajax_querystring','bpdev_exclude_users',20,2);
    function bpdev_exclude_users($qs=false,$object=false){
     //list of users to exclude
     
     $excluded_user='1';//comma separated ids of users whom you want to exclude
     
     if($object!='members')//hide for members only
     return $qs;
     
     $args=wp_parse_args($qs);
     
     //check if we are listing friends?, do not exclude in this case
     if(!empty($args['user_id']))
     return $qs;
     
     if(!empty($args['exclude']))
     $args['exclude']=$args['exclude'].','.$excluded_user;
     else
     $args['exclude']=$excluded_user;
     
     $qs=build_query($args);
     
     return $qs;
     
    }
    
    //Remove admin from member count
    
    add_filter('bp_get_total_member_count','bpdev_members_correct_count');
    function bpdev_members_correct_count($count){
    $excluded_users_count=1; //change it to the number of users you want to exclude
    return $count-$excluded_users_count;
    }
    ?>
    

    marmuel
    Participant

    @marmuel

    Hi there,

    I´ve added the code in the functions.php of my child-theme.
    In the “Who´s online”-widget, I still see the super admins. Any ideas to hide them in the widget?
    Thank you!
    Cheers
    Marco


    therandomguy12345
    Participant

    @therandomguy12345

    @philipstancil

    @bphelp

    I want to hide specific users from the “(BuddyPress) Recently Active Members” & “(BuddyPress) Members” widgets (latter one is most important for me), but I don’t want these users from the members directory. So what does the below code exactly do? Does it exclude users from members directory or the widgets? Or both?

    <?php
    // Remove admin from directory
    
    add_action('bp_ajax_querystring','bpdev_exclude_users',20,2);
    function bpdev_exclude_users($qs=false,$object=false){
     //list of users to exclude
     
     $excluded_user='1';//comma separated ids of users whom you want to exclude
     
     if($object!='members')//hide for members only
     return $qs;
     
     $args=wp_parse_args($qs);
     
     //check if we are listing friends?, do not exclude in this case
     if(!empty($args['user_id']))
     return $qs;
     
     if(!empty($args['exclude']))
     $args['exclude']=$args['exclude'].','.$excluded_user;
     else
     $args['exclude']=$excluded_user;
     
     $qs=build_query($args);
     
     return $qs;
     
    }
    
    //Remove admin from member count
    
    add_filter('bp_get_total_member_count','bpdev_members_correct_count');
    function bpdev_members_correct_count($count){
    $excluded_users_count=1; //change it to the number of users you want to exclude
    return $count-$excluded_users_count;
    }
    ?>

    robotnjik
    Participant

    @robotnjik

    I have similar request. We would like to exclude admins from groups. We set that only admins can create groups and now all groups have admin for a member. It is ok to have admin activity listed but we would like to hide admins from member listings on group pages. Is this code or part of code work on BP 1.8.1.?


    Josh Rosenau
    Participant

    @kadymahinder

    Hi –

    I share the need to restrict admin activity from sitewide tracking, but when I test the above code the admin still appears.

    Is this out of date?

    Please help.

    Thanks

Viewing 20 replies - 1 through 20 (of 20 total)
  • The topic ‘Feature request: Hide certain members’ is closed to new replies.
Skip to toolbar