Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Support: Creating & Extending

Existing and new plugins/components and themes.

Removing menus not working in BuddyPress 1.5 – help please;) (5 posts)

Started 8 months, 3 weeks ago by: jonnyauk

  • Profile picture of jonnyauk Jonnyauk said 8 months, 3 weeks ago:

    I’m developing on the trunk version of BP and seem to have hit a bit of a road block when trying to manipulate the BuddyPress menus.

    As per https://bpdevel.wordpress.com/2011/08/05/how-bp-1-5-load-order-changes-may-affect-your-plugins-or-themes/ I have tried the following functions wrapped up in a function and hooked upto bp_setup_nav ie:

    function ja_remove_activity_friends_subnav() {
        bp_core_remove_subnav_item( 'activity', 'friends' );
    }
    add_action( 'bp_setup_nav', 'ja_remove_activity_friends_subnav', 15 );

    This is in my bp-custom.php file in plugins. Sadly, it doesn’t seem to do anything;(

    I think I may be getting confused between bp_core_remove_nav_item() and bp_core_remove_subnav() – no matter what I try the menu remains unaffected.

    I have tried things like bp_core_remove_nav_item($bp->groups->slug, 'send-invites'); inside the function too, but without success.

    Am I doing something wrong – I’d hate to hack the core, but it may come to it if I can’t get this working sadly;( Any help would be much appreciated thanks!

  • Profile picture of jonnyauk Jonnyauk said 8 months, 3 weeks ago:

    Ah, my mistake – this code does actually work HOWEVER , I can’t get it to hide ‘Send Invites’ or anything else under the group menu… do I have to do something different?

    function ja_remove_navigation_tabs() {
    	bp_core_remove_nav_item('friends');
    	bp_core_remove_nav_item('settings');
    }
    add_action( 'bp_setup_nav', 'ja_remove_navigation_tabs', 15 );
  • Profile picture of jonnyauk Jonnyauk said 8 months, 3 weeks ago:

    So, the above function works for other menus I’ve tried (under profile) – but I can’t interact with the ‘groups’ menu… I have tried the following in the function above:

    bp_core_remove_subnav_item( 'groups', 'send-invites' );
    (And with global $bp):
    bp_core_remove_subnav_item( $bp->groups->slug, ‘send-invites’ );

    The problem I have is that I need to retain the invites functionality in certain group situations – I’m happy with my conditional code for this – no problemo… but just can’t get the above function to interact at-all with the group menu – in-fact I can’t remove anything from this menu – but I can from others?

    Any help would be MUCH appreciated – I’m tearing my hear out on this one;(

  • Profile picture of Boone Gorges Boone Gorges said 8 months, 3 weeks ago:

    In BuddyPress 1.5, the parent slug for an individual group is not ‘groups’ or $bp->groups->slug. Instead, it is the single item slug (ie the group slug). Try this:
    bp_core_remove_subnav_item( bp_get_current_group_slug(), 'send-invites' );

  • Profile picture of jonnyauk Jonnyauk said 8 months, 3 weeks ago:

    Thanks @boonebgorges – that’s perfect!

    Just in-case anyone else comes across this, here is the complete final function for removing the various navigation items from the group menu in BP1.5:

    function ja_remove_navigation_tabs() {
      bp_core_remove_subnav_item( bp_get_current_group_slug(), 'send-invites' );
      bp_core_remove_subnav_item( bp_get_current_group_slug(), 'members' );
      bp_core_remove_subnav_item( bp_get_current_group_slug(), 'admin' );
    }
    add_action( 'bp_setup_nav', 'ja_remove_navigation_tabs', 15 );