Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: question about Group filtering


Boone Gorges
Keymaster

@boonebgorges

This works for me.

function filter_groups_by_type_private( $a, $b ) {

$groups = $b->groups;

foreach( $groups as $key => $group ) {
if ( $group->status != 'private' ) {
unset( $groups[$key] );
$b->group_count = $b->group_count - 1;
}
}

$groups = array_values( $groups );
$b->groups = $groups;
return $b;
}
add_filter( 'bp_has_groups', 'filter_groups_by_type_private', 10, 2 );

Play around with the value ‘private’ to change what the function does.

It’s not perfect, because the pagination is not adjusted accordingly. You’d probably have to rebuild the core function in order to make pagination happen, since per_page gets passed right along to the database function. That’s why I say you might do well to write an enhancement ticket and submit it to trac.buddypress.org. In the meantime, though, this will set you in the right direction.

Skip to toolbar