Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • LogicWolf
    Participant

    @logicwolf

    Hi David,

    Hoping I’ll be able to help. I’ve seen alot of questions on the topic of How To Change and Reorder BuddyPress Group tabs and not much great direction. Hopefully you won’t be saying that after my posts… What I’m really hoping is someone comes in with a simpler, more elegant solution 🙂

    Were you able to control the standard tabs?

    For the standard group tabs, you can control them directly like this:

    if (isset($bp->groups->current_group->slug) && $bp->groups->current_group->slug == $bp->current_item) 
    {
            $bp->bp_options_nav[$bp->groups->current_group->slug]['home']['position'] = 10;
            $bp->bp_options_nav[$bp->groups->current_group->slug]['members']['position'] = 60;
            $bp->bp_options_nav[$bp->groups->current_group->slug]['notifications']['position'] = 110;
    }

    So the code to put in functions.php might look like this:

    function whff_setup_nav() 
    {
    
      if (isset($bp->groups->current_group->slug) && $bp->groups->current_group->slug == $bp->current_item) 
      {
         $bp->bp_options_nav[$bp->groups->current_group->slug]['home']['position'] = 10;
         $bp->bp_options_nav[$bp->groups->current_group->slug]['members']['position'] = 60;
         $bp->bp_options_nav[$bp->groups->current_group->slug]['notifications']['position'] = 110;
    }
    
    } 
    add_action( 'bp_setup_nav', 'whff_setup_nav', 100000 );

    CUSTOM BUDDYPRESS GROUP TABS
    Now, the non-standard tabs are the tricky ones. You can’t access them through $bp->bp_options_nav (at least I couldn’t figure out how to do this.)

    Nonstandard Group tabs through the $wp_filter global. A good starting point is to dump the $wp_filter variable and get a look at it’s guts. Add this code in functions.php:

    global $wp_filter;
        
    foreach ( (array)$wp_filter as $key => $value ) 
    {
       echo '<pre>';
       echo '<strong>' . $key . ': </strong><br />';
       print_r( $value );
       echo '</pre>';
    }
    

    $wp_filter is a bunch of nested arrays. Search through the output for your Group Tab Names (i.e. search for “Calendar”) and you will find something like this:

    [00000000746c6153000000004e38ec1f_register] => Array
                    (
                        [function] => Array
                            (
                                [0] => BP_Group_Calendar_Extension Object
                                    (
                                        [visibility] => private
                                        [enable_create_step] => 
                                        [enable_nav_item] => 1
                                        [enable_edit_item] => 
                                        [name] => Calendar
                                        [slug] => calendar
                                        [admin_name] => 
                                        [admin_slug] => 
                                        [create_name] => 
                                        [create_slug] => 
                                        [create_step_position] => 81
                                        [nav_item_position] => 40
                                        [nav_item_name] => 
                                        [display_hook] => groups_custom_group_boxes
                                        [template_file] => groups/single/plugins
                                    )
    
                                [1] => _register
                            )
    
                        [accepted_args] => 1
                    )
    

    That’s your Group tab and all the hooks you need to change attributes (in this case it’s the tab that says “Calendar”.)

    But… unfortunately you can’t use the [00000000746c6153000000004e38ec1f_register] as a handle — that string is random and changes every time. But, now you know the class name is BP_Group_Calendar_Extension Object and you can search for that in the $wp_filter array and make the changes.

    Hope this gets you closer, let me know how you make out. Cheers David!


    LogicWolf
    Participant

    @logicwolf

    Ok, an update. I did manage to track down the objects where this information is stored. It’s not handed to you on a plate by any means!

    I will post the code after I clean it up a bit, but if anybody is suffering through this here is a hint:

    1. Hooks are in different places for core vs plugin Group tabs

    2. Controls for the core “built in” tabs are handled and stored in bp_options_nav

    3. Group tabs added by plugins, if done properly, are created by extending BP_Group_Extension. The extended objects are added to the action stack via add_action. This places references to the instantiated object in the $wp_filter global. So… to change attributes like nav position, you have to crawl through the $wp_filter array, find the objects, check the class, and make the change right there in $wp_filter.

    Messy! I feel like I just took apart a car engine just to turn the windshield wipers off. But the dang Group tabs are reordered and renamed.


    LogicWolf
    Participant

    @logicwolf

    Not much luck with this so far 🙁

    I can track down the creation of new Group tabs in the plugins by looking for extensions of BP_Group_Extension. So for some of the tabs at least, in a pinch, I can edit the plugin code directly but this is a messy solution in my opinion…

    Any suggestions on how I might find the Group tab hooks would greatly be appreciated!


    LogicWolf
    Participant

    @logicwolf

    To clarify on my type above:

    This code does NOT work (can’t reorder the forums tab):

    $bp->bp_options_nav[$bp->groups->current_group->slug]['forum']['position'] = '99';

    But this code DOES work (I can reorder the Home tab)

    $bp->bp_options_nav[$bp->groups->current_group->slug]['home']['position'] = '99';

    Thank you again for any help you can provide!

Viewing 4 replies - 1 through 4 (of 4 total)
Skip to toolbar