This code is based on a post from the buddypress forums tested on Buddypress 2.9.2 ( forum states its compatible from BP 2.6+).
In this example we remove the Delete tab and also permission so that user can’t try and goto the url to access it.
Note there are numerous other examples / versions of this code scattered about the bp forums that dont work as function bp_core_remove_subnav_item now requires the extra param (see code below).
important: Navigation API has lots of good up to date examples
function gwb_remove_group_admin_tab() {
if ( ! bp_is_group() || ! ( bp_is_current_action( 'admin' ) && bp_action_variable( 0 ) ) || is_super_admin() ) {
return;
}
// Add the admin subnav slug you want to hide in the
// following array
$hide_tabs = array(
'delete-group' => 1, // you can get this from view source of the page the id of tab is this
);
$parent_nav_slug = bp_get_current_group_slug() . '_manage';
// Remove the nav items
foreach ( array_keys( $hide_tabs ) as $tab ) {
// Since 2.6, You just need to add the 'groups' parameter at the end of the bp_core_remove_subnav_item
bp_core_remove_subnav_item( $parent_nav_slug, $tab, 'groups' );
}
// You may want to be sure the user can't access
if ( ! empty( $hide_tabs[ bp_action_variable( 0 ) ] ) ) {
bp_core_add_message( 'Sorry buddy, but this part is restricted to super admins!', 'error' );
bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) );
}
}
add_action( 'bp_actions', 'gwb_remove_group_admin_tab', 9 );
See this post also on hiding the delete tab on the groups from the buddypress forums
