Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Can someone explain how to add tabs to the profile page?


Justin Frydman
Participant

@defunctlife

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 );`

Skip to toolbar