Yes I’ve not played with that yet but from what I can see that’s the name of the function that will be called to display your content, it can call a template file.
Here’s an example, posted by Shanebp in the archives:
function add_iuda_tab() {
global $bp;
bp_core_new_nav_item( array(
'name' => 'Iuda',
'slug' => 'iuda',
'parent_url' => $bp->displayed_user->domain,
'parent_slug' => $bp->profile->slug,
'screen_function' => 'iuda_screen',
'position' => 200,
'default_subnav_slug' => 'iuda'
) );
}
add_action( 'bp_setup_nav', 'add_iuda_tab', 100 );
function iuda_screen() {
add_action( 'bp_template_title', 'iuda_screen_title' );
add_action( 'bp_template_content', 'iuda_screen_content' );
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}
function iuda_screen_title() {
echo 'iuda Title<br/>';
}
function iuda_screen_content() {
echo 'iuda Content<br/>';
}
The bp_core_template_plugin function is loading plugins.php
from the bp-templates
directory, which can be overloaded by placing your own template file in themes/child-theme/buddypress/members/single/plugins.php
that’s one way of doing it. another way is to register your own template directory (inside plugin for example) and tell bp to load that.
I have tried the code above, here:
add_action( 'bp_setup_nav', 'content_setup_nav_profile' );
function content_setup_nav_profile() {
bp_core_new_nav_item( array(
'name' => 'projects',
'slug' => 'project',
'screen_function' => 'XX_bp_projects_screen',
'position' => 20,
'default_subnav_slug' => 'project',
'item_css_id' => 'projects',
) );
}
function XX_bp_projects_screen() {
// We never get here for some reason
add_action( 'bp_template_title', 'XX_bp_projects_screen_title' );
add_action( 'bp_template_content', 'XX_bp_projects_screen_content' );
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
} //end function
function XX_bp_projects_screen_title() {
echo 'Projects<br/>';
}
function XX_bp_projects_screen_content() {
echo 'Dummy Content<br/>';
}
The icon shows, in the row with the others.
Yet, it never launches the function listed under ‘screen_function’, XX_bp_projects_screen()
I’m perplexed..
Thought I had an additional issue. ‘screen_function’ wasn’t getting reached. The theme was ALSO creating a menu item with the same slug.
Solved.