Sorry for posting in “installing”. Tried to edit, but it takes me to buddypress.org main page. Wont allow me to edit.
Topic moved to Creating & Extending forum
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' );
Sorry I thought I was clear. I dont need an example of how to create the tab and the submenus.
What I did was write a class that creates a top level member area tab called Favorites that consolidates all types of favorites within a single tab. https://github.com/colabsadmin/bp-favorites/blob/master/bp-favorites.php
The submenus that have been created so far are Activity, Topics, Posts and a few more for some CPTs that I’ve written. This will make it easier for my users to find their favorites when they cant remember if it came from a topic, posts, activity, etc. Instead of jumping around from tab to tab, its all in one tab. The only submenu that doesnt work is Activity. The code, which I provided in my first question, was copied directly from Buddypress core code with one change to use ‘bp_core_new_subnav_item’. I used similar code to display content in all the other submenus. For example, the following shows the favorite topics
// Favorite topics
bp_core_new_subnav_item( array(
'name' => __( 'Topics', 'kleo' ),
'slug' => "topics",
'parent_url' => $bp->displayed_user->domain . $bp->bp_nav['favorites']['slug'] . '/',
'parent_slug' => $bp->bp_nav['favorites']['slug'],
'screen_function' => 'bbp_member_forums_screen_favorites',
'position' => 10,
'item_css_id' => 'favorites'
));
So, my question, does bp_activity_screen_favorites() only work within the context of /members/membername/activity action? Or can it be used elsewhere as in /members/membersname/favorites?
bp_activity_screen_favorites()
loads that screen.
Try using: bp_activity_get_user_favorites()
Looking thru the source code will answer these kinds of questions.
That’s what I’m trying to do. Load that screen, but under a different tab.
The only way I got this to work is by duplicating the activity loop (passing the scope=favorites argument) and all of the code that formats the activities, which I was trying to avoid.