Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to hide / remove the General tab under Settings


  • sherissa_r
    Participant

    @sherissa_r

    Hi, we are using Digital Access Pass (DAP) to create members/users. We are using a child theme.

    What is the best way to hide/remove the General tab under settings, as we do not want members updating their password or email on this page.

    Thank you

Viewing 9 replies - 1 through 9 (of 9 total)

  • sherissa_r
    Participant

    @sherissa_r

    WP 4.6.1
    Buddy press 2.6.2


    danbp
    Moderator

    @danbp

    Hi @sherissa_r,

    General is the default landing tab for profile settings.
    To remove it, you use these functions:
    to remove the item -> bp_core_remove_subnav_item()
    to define a new one -> bp_core_new_nav_default()

    You may also want to remove General from usermenu if you use WP’s toolbar, in which case you need -> $wp_admin_bar->remove_node()

    Note that General is also the default sub-nav template for all other Settings (Emails & Profile visibility). When you remove the item, you remove also the template. That’s why you need to define a new landing tab.
    Note also that once General is removed, you will only see the other settings buttons, but no the content of the new defined tab. It will only appear once you clicked on the button.

    Here the snippets you could test (add them to bp-custom)

    function bpex_change_profile_settings_default_tab() {
    
    	if( bp_is_active( 'xprofile' ) ) :
    
    	$access        = bp_core_can_edit_settings();
    	$slug          = bp_get_settings_slug();
    
    	$args = array(
    		'parent_slug'     => $slug,
    		'subnav_slug'	  => $slug . '/notifications/',
    		'screen_function' => 'bp_settings_screen_notification',
    		'user_has_access' => $access
    		);
     
    	bp_core_new_nav_default( $args );
    
    	endif;
    
    }
    add_action( 'bp_actions', 'bpex_change_profile_settings_default_tab' );
    
    function bpex_remove_general_item_on_usermenu() {
    global $wp_admin_bar;
    
    	if ( bp_use_wp_admin_bar() ) {
    		$wp_admin_bar->remove_node( 'my-account-settings-general' );
    	}
    
    }
    add_action( 'wp_before_admin_bar_render', 'bpex_remove_general_item_on_usermenu' );
    
    function bpex_remove_profile_settings_general_tab() {
    
    	if( bp_is_active( 'xprofile' ) ) :	
    
    		bp_core_remove_subnav_item( 'settings', 'general' );
    
    	endif;
    
    }
    add_action( 'bp_actions', 'bpex_remove_profile_settings_general_tab' );

    sherissa_r
    Participant

    @sherissa_r

    Thank you Dan, I created a bp-custom.php in my plugins folder.
    I inserted the code snippet you provided above. It works as you described. Removing the General tab and its contents and just showing the Email and Profile Visibility tabs.

    Is it possible to have the contents of the Email tab load automatically?


    danbp
    Moderator

    @danbp

    Is it possible to have the contents of the Email tab load automatically?

    Afaik no. While testing the snippets, i discovered that none of the tab show his content when you remove the General tab. I ignore if it is a bug (and doubt it is one) or intended so. In fact, profile settings are not intented to be removed, but that’s pure theory. 🙂
    The funny news is that i can display the content of third party plugins who share the profile settings tab with BP. Conclusion: BP hide the whole settings content, but other plugins can still use it.
    Strange and not user friendly – and never mentionned on this forum so far i know. But i must admit it is an exceptionnal case.

    Maybe calling @djpaul or @dcavins to this topic can bring another opinion ? I go to mention this on Slack immediatly, so hopefully we will be quicly fixed.

    Wait and see ! 🙂


    danbp
    Moderator

    @danbp

    hi @sherissa_r,
    i asked on Slack where @hnla answered that “clearly something is wrong”. I opened a ticket, just in case of.

    Now we’ve to wait a little moment the time a dev can investigate this.

    I saw the bug report you’ve filed, Dan, but I’ve not had time to look into it.


    Lena Stergatou
    Participant

    @lenasterg

    Hi. I made a minor change in the code @danbp suggests (basically the $args[‘subnav_slug’] and now I believe it works as expected.
    So I guess it’s not a BuddyPress bug.

    Please, try the following

    
    function bpex_change_profile_settings_default_tab() {
    
    	if( bp_is_active( 'xprofile' ) ) :
    
    	$access        = bp_core_can_edit_settings();
    	$slug          = bp_get_settings_slug();
    
    	$args = array(
    		'parent_slug'     => $slug,
    		'subnav_slug'	  => 'notifications',
    		'screen_function' => 'bp_settings_screen_notification',
    		'user_has_access' => $access
    		);
     
    	bp_core_new_nav_default( $args );
    
    	endif;
    
    }
    add_action( 'bp_actions', 'bpex_change_profile_settings_default_tab' );
    
    function bpex_remove_general_item_on_usermenu() {
    global $wp_admin_bar;
    
    	if ( bp_use_wp_admin_bar() ) {
    		$wp_admin_bar->remove_node( 'my-account-settings-general' );
    	}
    
    }
    add_action( 'wp_before_admin_bar_render', 'bpex_remove_general_item_on_usermenu' );
    
    function bpex_remove_profile_settings_general_tab() {
    
    	if( bp_is_active( 'xprofile' ) ) :	
    
    		bp_core_remove_subnav_item( 'settings', 'general' );
    
    	endif;
    
    }
    add_action( 'bp_actions', 'bpex_remove_profile_settings_general_tab' );

    Prime Aque
    Participant

    @junjuvy15

    @lenasterg this solution works! Thank you very much!


    Leandro
    Participant

    @leandrorocha

    Hello!

    Someone knows if the code still working with the version 3.1.0?

    I remember to have used the code from @lenasterg with the version 2.9.4 and was working perfectly but now with a website running the version 3.1.0 the code doesnt redirect the old setting URL to setting/notification anymore.

    I am looking for a way to remove the general tab and redirect the setting URL to notifications. I already have a page where users can change their password so have two places where someone can edit the same information is a bit confusing.

    —-

    MOD EDIT – View the following thread for updated info:

    Removing Settings General tab redirect to Other Tab

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to hide / remove the General tab under Settings’ is closed to new replies.
Skip to toolbar