Created
June 28, 2016 19:03
-
-
Save imath/fe55bac10b2b5a7fe486784afaa76327 to your computer and use it in GitHub Desktop.
How to remove admin tabs for Groups single items.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
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 ) { | |
// 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', 'turker_remove_group_admin_tab', 9 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment