Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide Account from Member Directory


  • slash75
    Participant

    @slash75

    I want to prevent several accounts from displaying in the Members Directory.
    Ex. Administrators

    Is t his possible?

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

  • Prashant Singh
    Participant

    @prashantvatsh

    add_action('bp_ajax_querystring','ps_exclude_admin_members',20,2);
    function ps_exclude_admin_members($qs=false,$object=false){
         
        if($object!='members')
            return $qs;
            
        $excluded_user = implode(',',get_users('role=administrator&fields=ID'));
      
        
        $args=wp_parse_args($qs);
        
        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;
        
    }

    Hi,

    Please paste the above code in child theme’s functions.php and test.

    Hopefully, it will help you.

    Thanks


    slash75
    Participant

    @slash75

    That worked. Thanks!


    Prashant Singh
    Participant

    @prashantvatsh

    Glad to know that 🙂

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