BuddyPress: Remove Profile Tabs You Don't Need
Removes tabs from BuddyPress member profiles, such as Friends or Groups, while leaving the components switched on elsewhere.
Opens WPIDE on
Code
if ( ! function_exists( 'buddypress' ) ) {
return;
}
// Profile tabs (or parent/child sub-tabs) to remove.
$wpide_bp_removed_tabs = array( 'friends', 'settings/profile' );
add_action( 'bp_setup_nav', function () use ( $wpide_bp_removed_tabs ) {
foreach ( $wpide_bp_removed_tabs as $tab ) {
if ( false !== strpos( $tab, '/' ) ) {
list( $parent, $child ) = explode( '/', $tab, 2 );
bp_core_remove_subnav_item( $parent, $child );
} else {
bp_core_remove_nav_item( $tab );
}
}
}, 1000 );
Notes
Use tab slugs such as friends, groups, notifications, messages or settings. To remove a sub-tab add "parent/child", for example "settings/profile".
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.