Skip to:
Content
Pages
Categories
Search
Top
Bottom

how to hide a plugin generated buddypress tab

  • @urbanfix

    Participant

    WP+BP Versions= Latest.
    urban-fix.co.uk

    I would like to hide a plugin generated buddypress tab, so after looking around I found this code and modified it a little:

    <?php
    function bp_remove_nav_item() {
    if(current_user_cannot(“access_s2member_level2″))
    global $bp;
    
    bp_core_remove_subnav_item( $bp->profile->slug, ‘change-avatar’ );
    }
    add_action( ‘wp’, ‘bp_remove_nav_item’ );
    ?>

    This worked perfectly well so i edited the following line:
    bp_core_remove_subnav_item( $bp->profile->slug, ‘change-avatar’ );
    to
    bp_core_remove_nav_item('listings');

    And now the full code looks like this;

    function bp_remove_nav_item() {
    if(is_user_logged_in("true") )
    if(current_user_cannot("access_s2member_level2"))
        global $bp;
    
        bp_core_remove_nav_item('listings');
    }
    add_action( 'wp', 'bp_remove_nav_item' );

    However this removes the ‘listings’ tab for all, any idea what im doing wrong?
    Thanks in advance,

Viewing 4 replies - 1 through 4 (of 4 total)
  • @shanebp

    Moderator

    Please do not double post.

    try this:

    function urbanfix_remove_nav_item() {
    
       if( current_user_cannot("access_s2member_level2") )
           bp_core_remove_nav_item('listings');
    }
    add_action( 'wp', 'urbanfix_remove_nav_item' );

    @urbanfix

    Participant

    Sorry!
    I was trying to just post one but it kept saying error so i posted again!
    It worked perfectly, just for future reference, why am i using the urbanfix_remove etc?
    Thanks a bunch!

    @shanebp

    Moderator

    Re Sorry: no problem, this forum can be buggy.

    >why am i using the urbanfix_remove

    You mean as a function name? It’s usually better not to use ‘bp_(etc)’ to avoid confusion and more importantly conflicts with BP code or code from other plugins.
    http://nacin.com/2010/05/11/in-wordpress-prefix-everything/

    @urbanfix

    Participant

    Ah okay thankyou!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘how to hide a plugin generated buddypress tab’ is closed to new replies.
Skip to toolbar