Reply To: How to remove tabs from group admin nav
Hi @danbp asked me about this.. So here’s a way to hide the tabs
function turker_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(
'group-avatar' => 1,
'delete-group' => 1,
);
$parent_nav_slug = bp_get_current_group_slug() . '_manage';
// Remove the nav items
foreach ( array_keys( $hide_tabs ) as $tab ) {
bp_core_remove_subnav_item( $parent_nav_slug, $tab );
}
// 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', 'turker_remove_group_admin_tab', 9 );