Skip to:
Content
Pages
Categories
Search
Top
Bottom

Members directory showing all useres on multisite


  • fidelduque
    Participant

    @fidelduque

    Hi, I’m using Buddypress Version 2.5.3 and WordPress 4.5.2.

    I’m running a multisite wordpress installation, Right now I’m trying to exclude the suscribers in the members directory, this is the code i found:

    function bpdev_exclude_users($qs=false,$object=false){
        //list of users to exclude
         
        if($object!='members')//hide for members only
            return $qs;
            
        $excluded_user = implode(',',get_users('role=subscriber&fields=ID'));
        $excluded_admins = implode(',',get_users('role=administrator&fields=ID'));
        //$excluded_self=bp_loggedin_user_id();
    	
        
        $args=wp_parse_args($qs);
        
        //check if we are searching for friends list etc?, do not exclude in this case
        if(!empty($args['user_id']))
            return $qs;
        
        if(!empty($args['exclude'])){		
            $args['exclude']=$args['exclude'].','.$excluded_user;
            $args['exclude']=$args['exclude'].','.$excluded_admins;
            //$args['exclude']=$args['exclude'].','.$excluded_self;
        } else {
            $args['exclude']=$excluded_user;		
    		if(!empty($args['exclude']))
    			$args['exclude']= $args['exclude'].','.$excluded_admins;
    		else
    			$args['exclude']=$excluded_admins;
            //$args['exclude']=$excluded_self;
        }
        $qs=build_query($args);
       
       return $qs;  
    }
    add_action('bp_ajax_querystring','bpdev_exclude_users',20,2);

    but right now, the get_users function won’t show any subscriber because there are not suscribers on this site, but on the other ones. Anyway, the buddypress is showing all users including the ones in the other sites.

    any hint?

    Thanks

Viewing 1 replies (of 1 total)

  • fidelduque
    Participant

    @fidelduque

    Done, I added this to the queryString:

    global $wpdb, $current_blog;
    $id = $current_blog->blog_id;
    // Setting variable for current blog_prefix
    $blog_prefix = $wpdb->get_blog_prefix( $id );
    
    if ( bp_has_members( $queryString. '&per_page=21&meta_key='.$blog_prefix.'capabilities') ) :
    
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar