Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Hide Custom Tab Only To Account Owner & Admin


  • buckyb
    Participant

    @buckybeever

    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!

Viewing 3 replies - 1 through 3 (of 3 total)

  • Brajesh Singh
    Participant

    @sbrajesh

    Hi @buckybeever,
    You need to change one line

    change this

    
    'show_for_displayed_user' => true,
    
    

    to this

    
    'show_for_displayed_user' => bp_is_my_profile() || is_super_admin(),
    
    

    That will do it. Hope it helps.


    buckyb
    Participant

    @buckybeever

    Thank you so much! Yep it works 🙂


    Brajesh Singh
    Participant

    @sbrajesh

    No problem. Glad to help 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Hide Custom Tab Only To Account Owner & Admin’ is closed to new replies.
Skip to toolbar