Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BuddyPress add profile tab and subnav
function add_animal_tabs() {
global $bp;
bp_core_new_nav_item( array(
'name' => 'Animals',
'slug' => 'animals',
'parent_url' => $bp->displayed_user->domain,
'parent_slug' => $bp->profile->slug,
'screen_function' => 'animals_screen',
'position' => 200,
'default_subnav_slug' => 'animals'
) );
bp_core_new_subnav_item( array(
'name' => 'Dogs',
'slug' => 'dogs',
'parent_url' => trailingslashit( bp_displayed_user_domain() . 'animals' ),
'parent_slug' => 'animals',
'screen_function' => 'dogs_screen',
'position' => 100,
'user_has_access' => bp_is_my_profile()
) );
bp_core_new_subnav_item( array(
'name' => 'Cats',
'slug' => 'cats',
'parent_url' => trailingslashit( bp_displayed_user_domain() . 'animals' ),
'parent_slug' => 'animals',
'screen_function' => 'cats_screen',
'position' => 150,
'user_has_access' => bp_is_my_profile()
) );
}
add_action( 'bp_setup_nav', 'add_animal_tabs', 100 );
function animals_screen() {
add_action( 'bp_template_title', 'animals_screen_title' );
add_action( 'bp_template_content', 'animals_screen_content' );
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}
function animals_screen_title() {
echo 'Animals Title<br/>';
}
function animals_screen_content() {
echo 'Animals Content<br/>';
}
function dogs_screen() {
add_action( 'bp_template_content', 'dogs_screen_content' );
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}
function dogs_screen_content() {
echo 'Dogs';
}
function cats_screen() {
add_action( 'bp_template_content', 'cats_screen_content' );
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}
function cats_screen_content() {
echo 'Cats';
}
@danTsybulnyk

This comment has been minimized.

Copy link

@danTsybulnyk danTsybulnyk commented Sep 22, 2020

Thank you! Thank you! Thank you! Thank you! Thank you! Thank you!

@Gaeius

This comment has been minimized.

Copy link

@Gaeius Gaeius commented Oct 10, 2020

How and where to add this code mam/sir?

@shanebp

This comment has been minimized.

Copy link
Owner Author

@shanebp shanebp commented Oct 10, 2020

In a plugin, in bp-custom.php or in your child theme -> functions.php

@Gaeius

This comment has been minimized.

Copy link

@Gaeius Gaeius commented Oct 11, 2020

Ok! Thank you so much. I'm currently using BuddyPress to organize our online school since COVID prohibited us to operate physically. This really helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.