Halloween Sale 15% off Ends in See the plans
PHP

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.

Don’t have WPIDE yet? Install it on your site

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

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.