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
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()
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/
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()”?
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?
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( ) {
}