Search
Close this search box.

How to remove subnav menu item in BuddyPress

To remove a subnav menu item in BuddyPress, you can use the bp_core_remove_subnav_item() function. This function allows you to remove a subnav menu item from a user’s profile page or a group’s profile page.

Here’s an example of how you can use the bp_core_remove_subnav_item() function to remove a subnav menu item from a user’s profile page:

// Remove subnav menu item in BuddyPress
// More snippets at wpunplugged.com 

/**
 * @param int $user_id The ID of the user.
 */
function my_bp_remove_subnav_item( $user_id ) {
    // Check if the current user is the user being viewed
    if ( $user_id == bp_loggedin_user_id() ) {
        // Remove the "My Custom Tab" subnav item
        bp_core_remove_subnav_item( 'activity', 'my-custom-tab' );
    }
}
add_action( 'bp_actions', 'my_bp_remove_subnav_item' );

This code will remove the “My Custom Tab” subnav menu item from the user’s profile page if they are the currently logged in user. You can modify this code to remove a different subnav menu item, or to remove the subnav menu item from a group’s profile page instead.

To add this code to your site, you can add it to your theme’s functions.php file.

Note that this code assumes that you have the BuddyPress plugin installed and activated on your WordPress site. If you don’t have BuddyPress installed, you will need to install and activate it before you can use the bp_core_remove_subnav_item() function.

Share this post

You might also like...

UpdraftPlus for WordPress Review
Backup

UpdraftPlus for WordPress Review

UpdraftPlus for WordPress is a powerful backup plugin that enables users to easily back up their website’s content, including the WordPress database, themes, plugins, and

Read More »

Comment

Your email address will not be published. Required fields are marked *