Your screen function needs to look something like this:
function my_contact_athlete_template() {
add_action( 'bp_template_content', create_function( '', "
bp_get_template_part( 'contact-athlete' );
" ) );
bp_core_load_template( 'members/single/plugins' );
}
Thank you but your solution is outdated. I’ve found it also while searching.
And thats the big problem with buddypress. There was an update about one year ago and everything changed. So nearly all common customizations do not work any more.
Thats the reason why the plugin ‘buddypress custom profile menu’ also doesn’t function anymore.
Fortunately I found the solution. It looks like this:
function profile_new_nav_item() {
global $bp;
bp_core_new_nav_item(
array(
'name' => 'Contact Athlete',
'slug' => 'contact_athlete',
'default_subnav_slug' => 'extra_sub_tab',
'position' => 160,
'screen_function' => 'view_manage_tab_main'
)
);
}
add_action( 'bp_setup_nav', 'profile_new_nav_item', 10 );
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
function view_manage_tab_main() {
add_action( 'bp_template_content', 'bp_template_content_main_function' );
bp_core_load_template( 'template_content' );
}
function bp_template_content_main_function() {
if ( ! is_user_logged_in() ) {
wp_login_form( array( 'echo' => true ) );
}
}
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
function profile_new_subnav_item() {
global $bp;
bp_core_new_subnav_item(
array(
'name' => 'Extra Sub Tab',
'slug' => 'extra_sub_tab',
'parent_url' => $bp->loggedin_user->domain . $bp->bp_nav[ 'contact_athlete' ][ 'slug' ] . '/',
'parent_slug' => $bp->bp_nav[ 'contact_athlete' ][ 'slug' ],
'position' => 10,
'screen_function' => 'view_manage_sub_tab_main'
)
);
}
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
add_action( 'bp_setup_nav', 'profile_new_subnav_item', 10 );
function view_manage_sub_tab_main() {
add_action( 'bp_template_content', 'bp_template_content_sub_function' );
bp_core_load_template( 'template_content' );
}
function bp_template_content_sub_function() {
if ( is_user_logged_in() ) {
bp_get_template_part('my-contact-form');
} else {
wp_login_form( array( 'echo' => true ) );
}
}
I hope it helps anyone.
Finally I’d like to say that I have never seen such a bad documentation in development as in buddypress. I know buddypress is free but WordPress is free too and they have a great doc.