Skip to:
Content
Pages
Categories
Search
Top
Bottom

Extending Groups Navigation

  • @crashutah

    Participant

    I’ve extended the BP_Group_Extension to be able to add some functionality using the Group API. Everything is working well for adding a step to the group creation process. However, I’m having trouble making that step available under the Admin menu in the Groups.

    When I look under the Group–>Admin menu, I see a link to be able to edit my extension. That link points to: http://domain.com/groups/name_of_group/admin/org-info However, when I click on that link nothing loads. Is there something I need to tell the Group API to make that link work? Do I need to use the function bp_core_add_subnav_item()? Seems like I shouldn’t since the link is already there under admin. I just need to figure out how to get the link to call the function that is being called during the group creation process.

Viewing 6 replies - 1 through 6 (of 6 total)
  • @r-a-y

    Keymaster

    You need to attach a screen function to your admin page.

    Check out the skeleton component plugin for more details:
    https://wordpress.org/extend/plugins/buddypress-skeleton-component/

    Or copy the structure of your favorite plugins ;)

    @crashutah

    Participant

    I checked that out r-a-y. It looks like the bp_core_add_subnav_item is where I attach a screen function. However, it seems like the Group API might be doing this on its own already? Otherwise why would the nav appear there in the first place? Seems like when I do “class BP_Org_Info extends BP_Group_Extension {}” there’s something built in to add the nav and attach the screen function, but I can’t see where and how to change it so it links properly.

    I did try like the skeleton component suggested and did the following which didn’t work for me. Maybe this is the way I have attach the screen function and I’m just calling it wrong? Here’s my code

    function org_info_add_subnav() {
    global $bp;
    bp_core_add_subnav_item( array(
    ‘name’ => __(‘Organization Info’, ‘buddypress’),
    ‘slug’ => $bp->org_info->slug,
    ‘parent_slug’ => BP_GROUPS_SLUG,
    ‘parent_url’ => $bp->loggedin_user->domain . $bp->group->slug . ‘/’,
    ‘position’ => 30,
    ‘screen_function’ => ‘display’ //Should this be a call to some part of the Group API?
    ));
    }
    add_action( ‘wp’, ‘org_info_add_subnav’, 2 );

    Maybe one of the options I’m passing into bp_core_add_subnav_item is wrong, but I also just noticed that I’m getting this in the error logs:
    PHP Fatal error: Call to undefined function bp_core_add_subnav_item()

    Do I have to include some other file to use bp_core_add_subnav_item()

    @r-a-y

    Keymaster

    You’ve declared “display” as screen_function in your org_info_add_subnav() function.

    So now, you need to create a “display()” function with some code to display your admin page.
    In the skeleton component, the function you would want to look at is “bp_example_screen_one()” for hints.

    Also is your plugin BP-aware?
    https://codex.buddypress.org/how-to-guides/make-your-plugin-buddypress-aware-v1-2/

    @crashutah

    Participant

    I do have a display function, but it’s inside the Group API class that I extended. Is that a problem? Can I call that function inside of the Group API extension? Or do I just need to create a new function that replicates what’s already being done in the group API extension? Although, that doesn’t seem like it should be necessary since it performs the same function as what’s being done when the group is created essentially.

    I’ll see if it’s BP-aware, but I think I did that. Is that why it could be throwing the error “Call to undefined function bp_core_add_subnav_item()”?

    @crashutah

    Participant

    It looks like the Group API does automatically add the link on the Nav under the Group–>Admin page if you set this value:

    var $enable_edit_item = true;

    If I set it to false, then the link in the admin for the group doesn’t appear. So, the question is once I set that to true. How do I tell the Group API which function it should use to handle the display for that item?

    @crashutah

    Participant

    Dang, I’m not sure how I missed this. There are 2 functions that are available in the group API that handle the display and editing of the screen that’s added to the admin function.
    function edit_screen() {
    }
    function edit_screen_save( ) {
    }

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Extending Groups Navigation’ is closed to new replies.
Skip to toolbar