Reply To: Displaying members favorite activities
There is already a my favorites tab in BuddyPress menu. Don’t know what you’re trying to do, but here is a code example you can try(or study).
Add it to your child-theme functions.php or bp-cutom.php
function my_test_setup_nav() {
global $bp;
$parent_slug = 'test';
$child_slug = 'test_sub';
//name, slug, screen, position, default subnav
bp_core_new_nav_item( array(
'name' => __( 'Company Labs' ),
'slug' => $parent_slug,
'screen_function' => 'my_test_page_function_to_show_screen',
'position' => 40,
'default_subnav_slug' => $child_slug
) );
//Add the subnav items to the profile/
// name, slug, parent_url, parent slug, screen function
// Tab
bp_core_new_subnav_item( array(
'name' => __( 'Company Favs' ),
'slug' => $child_slug,
'parent_url' => $bp->loggedin_user->domain . $parent_slug.'/',
'parent_slug' => $parent_slug,
'screen_function' => 'my_test_page_function_to_show_screen'
) );
}
// tab
function my_test_page_function_to_show_screen() {
//add title and content here – last is to call the members plugin.php template
add_action( 'bp_template_title', 'my_test_page_function_to_show_screen_title' );
add_action( 'bp_template_content', 'my_test_page_function_to_show_screen_content' );
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}
function my_test_page_function_to_show_screen_title() {
echo 'Taskforce Titled';
}
function my_test_page_function_to_show_screen_content() {
echo 'Taskforce content';
do_action( my_test_post);
}
add_action( 'bp_setup_nav', 'my_test_setup_nav' );
function my_test_fav_custom_content() {
?>
<h3>Hello Company !</h3>
<p>Lorem ipsum de facto est</p>
<?php
}
add_action( 'my_test_post', 'my_test_fav_custom_content' );