Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] How to remove tabs from group admin nav


  • Sven Lehnert
    Participant

    @svenl77

    Hi @imath,

    In this topic you write that the function you provided should work with BuddyPress Version 2.2
    https://buddypress.org/support/topic/how-to-remove-tabs-from-group-admin-nav/#post-230995

    
    function turker_remove_group_admin_tab() {
    	if ( ! bp_is_group() || ! ( bp_is_current_action( 'admin' ) && bp_action_variable( 0 ) ) || is_super_admin() ) {
    		return;
    	}
    
    	// Add the admin subnav slug you want to hide in the
    	// following array
    	$hide_tabs = array(
    		'group-avatar' => 1,
    		'delete-group' => 1,
    	);
    
    	$parent_nav_slug = bp_get_current_group_slug() . '_manage';
    
    	// Remove the nav items
    	foreach ( array_keys( $hide_tabs ) as $tab ) {
    		bp_core_remove_subnav_item( $parent_nav_slug, $tab );
    	}
    
    	// You may want to be sure the user can't access
    	if ( ! empty( $hide_tabs[ bp_action_variable( 0 ) ] ) ) {
    		bp_core_add_message( 'Sorry buddy, but this part is restricted to super admins!', 'error' );
    		bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) );
    	}
    }
    add_action( 'bp_actions', 'turker_remove_group_admin_tab', 9 );
    

    There is still one issue with the manage link like named from @danbp

    The normal link is groups/GROUP-SLUG/admin/ and it will become a 404

    groups/GROUP-SLUG/admin/edit-details/ will work.

    How can I change the manage link to groups/GROUP-SLUG/admin/edit-details/

    or better do you have a working solution? Hope you can help.

    Cheers,
    Sven

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi @svenl77,

    It’s the case, just tested it and the function does what it intends to do : remove the group-avatar && the delete-group manage tabs.

    I don’t manage to reproduce your issue. If i go to groups/GROUP-SLUG/adminthen i’m automatically redirected to groups/GROUP-SLUG/admin/edit-details so no 404.

    My config is :
    fresh install
    WordPress latest trunk
    BuddyPress latest trunk
    twentytwelve

    I don’t think we’ve played in this area since 2.2.1

    FYI : if i add the edit-details to the list of restricted tabs, then the group admin cannot access to any manage page without knowing the url of the allowed tabs. So i’d say the edit-details should always be there.


    danbp
    Moderator

    @danbp

    Function tested with single install, BP 2.2 and 2012

    – connected as user (not super admin)
    – go to a group where i’m admin
    /groups/GROUP_SLUG/ -> OK

    – click on manage group – default tab Details
    /groups/GROUP_SLUG/admin/edit-details/ -> OK

    – removed buttons by function are:
    group-avatar & delete-group -> OK

    – click on Group Settings
    /groups/GROUP_SLUG/admin/group-settings/ -> OK

    Don’t see an issue. Front-end group management works correctly for me. And the function too.


    Sven Lehnert
    Participant

    @svenl77

    Hi @imath and @danbp,

    thanks for the fast replay. You are right. I have tested again on a fresh install and it works.

    I will dig into it and check why it dosen’t work on my other dev install.

    Many thanks 😉


    danbp
    Moderator

    @danbp

    @svenl77, why it dosen’t work on my other dev install.

    is haunted;-) or you use a redirect function to change the default group home tab ?


    javierllinas
    Participant

    @javierllinas

    Hello!

    Is this still the way to go with BP 2.6.0?
    I can’t get things to work (I want to remove ‘edit-settings’ and ‘delete-group’).

    By the way, why should the slug be “_manage” instead of “admin”?

    Thanks in advance,
    Javier


    danbp
    Moderator

    @danbp

    Get Ready! 2.4.0 will introduce important changes in Groups homes

    The function is still working, but not completely (tabs aren’t hidden). You probably need to complete it with $component (read above document)


    javierllinas
    Participant

    @javierllinas

    Thanks, @danbp!

    You are right: only the fallback was working bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) );.
    Adding the $component (which defaults to ‘members’) is the key:

    bp_core_remove_subnav_item( $parent_nav_slug, $tab, 'groups' );

    These functions are located in ‘bp-core/bp-core-buddybar.php’.
    I’d also want to get rid of ‘send-invites’ in group primary navigation, but this is not working for me:

    bp_core_remove_nav_item( 'send-invites', 'groups' );

    Thank you,
    Javier


    aapi001
    Participant

    @aapi001

    Hi does this still work in BP 2.7.2, WP 4.6.1?

    I’m new to coding, could someone help me out with exactly how I would add the $component to the code to get it to work? I’ve tried and its all failed. I am just trying to disable the ability to delete groups. Working in bp-custom.php Thanks!


    danbp
    Moderator

    @danbp

    @aapi001,

    please open your own topic. This one is marked as resolved and his subject is slightly different from your question.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] How to remove tabs from group admin nav’ is closed to new replies.
Skip to toolbar