4

I want to hide sub-nav in profile settings

enter image description here

I hide sub-nav comment "wp-content\plugins\buddypress\bp-settings\bp-settings-loader.php"

// Add General Settings nav item
    $sub_nav[] = array(
        'name'            => __( 'General', 'buddypress' ),
        'slug'            => 'general',
        'parent_url'      => $settings_link,
        'parent_slug'     => $this->slug,
        'screen_function' => 'bp_settings_screen_general',
        'position'        => 10,
        'user_has_access' => bp_core_can_edit_settings()
    );
Gerald Schneider
  • 17,416
  • 9
  • 60
  • 78

2 Answers2

1

What sub-nav item are you referring to? If you want to remove the Settings menu option entirely you can do this in a plugin or functions.php

function my_admin_bar_mod(){
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu( 'my-account-settings' );
}
add_action('wp_before_admin_bar_render','my_admin_bar_mod');

To remove just the Profile option under Settings use this instead:

$wp_admin_bar->remove_menu( 'my-account-settings-profile' );

UPDATE:

The following code will remove the General tab; I believe that is what you want. Correct? This code does that but I am seeing a problem. It might be a rewrite problem on my dev site where the Settings tab causes a 4040 error. Can you try this on your site and let me know?

function mcs_bp_remove_nav() {
    global $bp;
    bp_core_remove_subnav_item( $bp->settings->slug, 'general' );
}
add_action( 'bp_setup_nav', 'mcs_bp_remove_nav', 99);

Finally:

This code is needed in addition to the above. It changes Settings to point to the Email tab. It was defaulting to General and since that was removed we see a 404. This hook must fire earlier than the code that removes 'general'.

function mcs_bp_change_settings() {
    global $bp;
    // point setting to Email page (aka 'notifications')
    $args = array(  'parent_slug' => 'settings',
        'screen_function' => 'bp_core_screen_notification_settings',
        'subnav_slug' => 'notifications'
    );
    bp_core_new_nav_default( $args );
}
add_action( 'bp_setup_nav','mcs_bp_change_settingst', 5);
BillK
  • 317
  • 2
  • 11
  • Thanks.I disabled "General" and "Delete Account" sub-nav items. i do not want to disable settings menu. Is there a way to disable sub-nav item without commenting "wp-content\plugins\buddypress\bp-settings\bp-settings-loader.php" file – sujith kulasekara Feb 11 '16 at 08:06
  • Yes there is; but based on your question and the image you provided, it isn't clear to me what sub-nav items you are referring to. Are you trying to get rid of the General tab? The tern sub-nav is confusing me. – BillK Feb 11 '16 at 08:21
  • I think I now understand what you want; I updated my answer. Please let me know if this works and if you see the problem I mentioned. – BillK Feb 11 '16 at 08:51
  • Final update (I think). The last bit of code is needed to point settings to a new location since the general tab is now removed. That fixed my 404 error. – BillK Feb 11 '16 at 09:05
  • Thanks Billk. That works fine. I'm new to wordpress. – sujith kulasekara Feb 11 '16 at 10:54
0

To hide the sub-navigation in profile settings in BuddyPress, you can use custom CSS code.

Open your theme's CSS file. This file is usually named "style.css" and is located in your theme's directory.

Add the following code at the end of the CSS file:
/* Hide sub-navigation in BuddyPress profile settings */
.buddypress #item-nav {
    display: none;
}

You can even BuddyPress addons for more easy work