Hello,
Was wondering how to hide a custom tab I created and show it only to the account owner and the admin only.
This is my custom tab
function profile_new_nav_item() {
global $bp;
$post_count = count_user_posts_by_type( $bp->displayed_user->id );
bp_core_new_nav_item(
array(
‘name’ => ‘My Page’,
‘slug’ => ‘my-page’,
‘default_subnav_slug’ => ‘my-page’,
‘position’ => 30,
‘show_for_displayed_user’ => true,
‘screen_function’ => ‘view_manage_tab_main’,
‘parent_url’ => $bp->loggedin_user->domain . $bp->slug . ‘/’,
‘parent_slug’ => $bp->slug
)
);
}
function view_manage_tab_main() {
add_action( ‘bp_template_content’, ‘bp_template_content_main_function’ );
bp_get_template_part( ‘members/single/plugins’ );
}
function bp_template_content_main_function() {
if ( ! is_user_logged_in() && !bp_is_my_profile()) {
wp_login_form( array( ‘echo’ => true ) );
} else {
//Add content
include(locate_template(‘members/single/profile/my-page.php’));
}
}
add_action( ‘bp_setup_nav’, ‘profile_new_nav_item’, 50 );
Thanks!