Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP exclude member role


  • pws2015
    Participant

    @pws2015

    Hello,
    in page member i can exclude member by role and i see a right result but the problem i have wrong calcul total member in the filter! how i can fix it?

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

  • Henry Wright
    Moderator

    @henrywright

    but the problem i have wrong calcul total member in the filter

    Which filter?


    pws2015
    Participant

    @pws2015

    in page member i see “All members (total of members)”.. in total i see 11 but i have just 1 user on result!


    Henry Wright
    Moderator

    @henrywright

    Can you paste the code you’re using?


    pws2015
    Participant

    @pws2015

    Hi,
    In this file: wp-content/plugins/bp-custom.php i add this:

    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 );
    	}
    	
    $tab_role=array('administrator','subscriber','author','contributor','editor');
    	foreach($tab_role as $k=>$role){
    	//$role = ;//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;
    }
    

    So i exclude all role but i have custom role which users of this role are only can see they profiles in member page


    Henry Wright
    Moderator

    @henrywright

    You should use bp_parse_args(). Check out this article:

    Using bp_parse_args() to filter BuddyPress template loops


    danbp
    Participant

    @danbp

    Hi @pws2015,

    please use [code] button when you insert code in a post. Thx.

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