Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Custom Groups or activating different plugins in different groups?


Boone Gorges
Keymaster

@boonebgorges

(Sorry in advance that this answer is full of code. There is currently no easy way to do what you want to do, though with some coding it can be done pretty easily.)

Plugins generally create new group tabs through the BP Group Extension API: https://codex.buddypress.org/developer-docs/group-extension-api/ So a relatively quick way to keep certain tabs from appearing on certain groups is to modify the enable_nav_item() method, as shown under ‘Advanced Usage’ on that page. You’d have to do this to the plugins themselves.

If you’d prefer not to modify the plugins (which would be quite understandable) you could remove nav items after the fact with bp_core_remove_subnav_item(), defined in bp-core.php. This would take a lot of tweaking (and this is totally untested, so you’d have to experiment) but something in bp-custom.php like the following might work for you:

`function boone_limit_gallery_visibility() {
global $bp;

if ( !groups_get_groupmeta( $bp->groups->current_group->id, ‘show_gallery’ ) )
bp_core_remove_subnav_item( ‘groups’, ‘gallery’ );
}
add_action( ‘bp_setup_nav’, ‘boone_limit_gallery_visibility’, 999 );`

This assumes a couple things: 1) that your gallery plugin uses the term ‘gallery’ to name the subnav item, and 2) that you have already created a piece of group metadata ‘show_gallery’ for all groups that should see the gallery. You could also hardcode an array of group ids, like so:

`function boone_limit_gallery_visibility() {
global $bp;

$gallery_array = array( 3, 6, 10, 12, 14 );

if ( !in_array( $bp->groups->current_group->id, $gallery_array) )
bp_core_remove_subnav_item( ‘groups’, ‘gallery’ );
}
add_action( ‘bp_setup_nav’, ‘boone_limit_gallery_visibility’, 999 );`

That might be easier to get up and running at first, while you build the markup and functions necessary to save groupmeta.

Skip to toolbar