Can someone explain how to add tabs to the profile page?
-
Hi there,
I would like to add a blog tab to my buddypress profile page which is just a custom template/loop from wordpress posts, but I’m having trouble trying to figure out the best way to add a tab.
Could someone explain?
Thank you
-
No one out there knows the best way to do this?
have a look at the bp_core_new_subnav_item function
something like
`
bp_core_new_subnav_item( array( ‘name’ => ‘My Profile Page’ ), ‘slug’ => ‘my-profile-page’, ‘parent_url’ => $bp->loggedin_user->domain . $bp->profile->slug . ‘/’, ‘parent_slug’ => $bp->profile->slug, ‘screen_function’ => ‘my_profile_page_function_to_show_screen’, ‘position’ => 40 ) );
`then the screen function to render the page:
`
function my_profile_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_profile_page_function_to_show_screen_title’ );
add_action( ‘bp_template_content’, ‘my_profile_page_function_to_show_screen_content’ );
bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
}
``
function my_profile_page_function_to_show_screen_title() {
echo ‘something’;
}
`
`
function my_profile_page_function_to_show_screen_content() {//do something here for the page content
}
`Thanks Rich, can this be done without editing the core?
Never mind, I see you named them as my_profile_page function. Will be giving this a try today. Thank you!
you can add this to whatever functions/bp-custom file – the above code is incomplete and only serves as a rough guideline.
been messing with this and got it to work but not sure how to get a sub nav working. I have a tab next to profile but want to have sub navs.
`function my_test_setup_nav() {
global $bp;
bp_core_new_nav_item( array( ‘name’ => __( ‘test’ ), ‘slug’ => ‘test’, ‘parent_url’ => $bp->loggedin_user->domain . $bp->slug . ‘/’, ‘parent_slug’ => $bp->slug, ‘screen_function’ => ‘my_profile_page_function_to_show_screen’, ‘position’ => 40 ) );bp_core_new_subnav_item( array( ‘name’ => __( ‘Home’ ), ‘slug’ => ‘test_sub’, ‘parent_url’ => $bp->loggedin_user->domain . $bp->slug . ‘/’, ‘parent_slug’ => $bp->slug, ‘parent_slug’ => $bp->slug, ‘screen_function’ => ‘my_profile_page_function_to_show_screen’, ‘position’ => 20, ‘item_css_id’ => ‘test_activity’ ) );
function my_profile_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_profile_page_function_to_show_screen_title’ );
add_action( ‘bp_template_content’, ‘my_profile_page_function_to_show_screen_content’ );
bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
}
function my_profile_page_function_to_show_screen_title() {
echo ‘something’;
}
function my_profile_page_function_to_show_screen_content() {echo ‘weee content’;
}
}
add_action( ‘bp_setup_nav’, ‘my_test_setup_nav’ );
`wrap the bp_core_new_subnav_item call in a function which is hooked on xprofile_setup_nav action (if that is installed, i don’t recall the name of the regular profile setup_nav action)
oops, i guess you could use
bp_core_new_nav_item
as well – i was just copying my example code from a plugin of mine which places it under the ‘Profile’ navI was looking at one of @djpaul ‘s plugins to see how the sub nav items were added below but I can’t seem to get it to show up.
Thank you both for your help, so I’m hoping I can return the favor. Modemlooper, here is how I adjusted the My Friends tab, but it has sub nav code for you, maybe it will help. Credit for this from @jeffsayre
`function my_friends_setup_nav() {
global $bp;/* Add ‘Friends’ to the main navigation */
if( bp_friend_get_total_requests_count($disp_user) > 0 && bp_is_my_profile()) {
bp_core_new_nav_item( array( ‘name’ => sprintf( __( ‘Friends (%d) (%d)‘, ‘buddypress’ ), friends_get_total_friend_count(), bp_friend_get_total_requests_count() ), ‘slug’ => $bp->friends->slug, ‘position’ => 60, ‘screen_function’ => ‘friends_screen_my_friends’, ‘default_subnav_slug’ => ‘my-friends’, ‘item_css_id’ => $bp->friends->id ) );
} else {
bp_core_new_nav_item( array( ‘name’ => sprintf( __( ‘Friends (%d)‘, ‘buddypress’ ), friends_get_total_friend_count() ), ‘slug’ => $bp->friends->slug, ‘position’ => 60, ‘screen_function’ => ‘friends_screen_my_friends’, ‘default_subnav_slug’ => ‘my-friends’, ‘item_css_id’ => $bp->friends->id ) );
}$friends_link = $bp->loggedin_user->domain . $bp->friends->slug . ‘/’;
/* Add the subnav items to the friends nav item */
bp_core_new_subnav_item( array( ‘name’ => __( ‘My Friends’, ‘buddypress’ ), ‘slug’ => ‘my-friends’, ‘parent_url’ => $friends_link, ‘parent_slug’ => $bp->friends->slug, ‘screen_function’ => ‘friends_screen_my_friends’, ‘position’ => 10, ‘item_css_id’ => ‘friends-my-friends’ ) );
bp_core_new_subnav_item( array( ‘name’ => sprintf( __( ‘Requests (%d)‘, ‘buddypress’ ), bp_friend_get_total_requests_count() ), ‘slug’ => ‘requests’, ‘parent_url’ => $friends_link, ‘parent_slug’ => $bp->friends->slug, ‘screen_function’ => ‘friends_screen_requests’, ‘position’ => 20, ‘user_has_access’ => bp_is_my_profile() ) );if ( $bp->current_component == $bp->friends->slug ) {
if ( bp_is_my_profile() ) {
$bp->bp_options_title = __( ‘My Friends’, ‘buddypress’ );
} else {
$bp->bp_options_avatar = bp_core_fetch_avatar( array( ‘item_id’ => $bp->displayed_user->id, ‘type’ => ‘thumb’ ) );
$bp->bp_options_title = $bp->displayed_user->fullname;
}
}do_action( ‘friends_setup_nav’ );
}add_action( ‘bp_setup_nav’, ‘my_friends_setup_nav’, 11 );`
@modemlooper Looks like the above should sort you out? Let me know.
Thanks, I’l mess with it
Hi guys,
Thanks for the code it worked perfectly for me. However under the new tab in the page content I want to add a products feed from the wp-ecommerce plugin.
So for example my new tab is “my products” instead of the test one above. Usually to put the products on the page you would just put in [productspage] however this isn’t working for me its just throwing up errors. I’ve tried putting it in an echo statement like the above example has wee contentso I’ve put echo ‘ [productspage] ‘;
But this just prints the words [productspage] to the screen. Usualy these keywords would show up all the products on the screen…. any ideas??
Thanks again for the tab code!
i’m using wpmu 2.9.2 and qTranslate. when i turn qTranslate tabs are not translated. why? everything else is translated normally.
`
bp_core_new_subnav_item( array( ‘name’ => sprintf( __( ‘Members (%s)’, ‘buddypress’ ), number_format( $bp->groups->current_group->total_member_count ) ), ‘slug’ => ‘members’, ‘parent_url’ => $group_link, ‘parent_slug’ => $bp->groups->slug, ‘screen_function’ => ‘groups_screen_group_members’, ‘position’ => 60, ‘user_has_access’ => $bp->groups->current_group->user_has_access, ‘item_css_id’ => ‘members’ ) );
`Hey guys,
Regarding @nuprn1 post, bp_get_displayed_user_nav() is not displaying any tabs on this custom page.
Any ideas?
Never mind, it’s something I changed as it works in the default template.
@nuprn1 how can I add a tab after the forum tab ?
is there a plugin for this?
Not currently, but it’s a good idea. I might do a plugin in the future where you can add as many tabs as you want, to profile, or groups.
please do that !! – with some explanation or some possibility how to get the content below that Tab or sub Tab (text , images ) the best should be some self creating custom fields form on the EDIT subnav page ( and the content on the publishes part – the similar process how profile EDIT and PUBLIC subnav Tabs works .
I would allow the Admins to have a Admin Page in the Backend with options to create more tabs, and the content on the tab
Go @gunju2221 !
@virtuali I was thinking the exact same thing today – in other CMSs I’ve used, I’ve been able to see a treeview of the navigation for the entire site and put any items I wanted in any spots (or rather, any items other people wanted 07 ). Since BP uses a common header file and seems to do its own setups for each tab (although I haven’t looked at everything yet) this might not be an impossible dream.
This would perk up Buddypress’ design and usability options a LOT. My particular configuration is moving the “My” subtab from the Profile out to each main tab. While I’ve found code to remove the subtabs from the Profile view, I found this post looking for how to add those subtabs, just as they are, to the main tabs.
Also, let me throw this link in here as references as to how to configure the existing tabs on groups and profiles (reorder, rename, remove):
http://themekraft.com/2011/02/customize-profile-and-group-menus-in-buddypress
@dains, your enclosed link no longer works. The following should:
- The topic ‘Can someone explain how to add tabs to the profile page?’ is closed to new replies.