Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Editing New WordPress Toolbar

  • @iamdhunt

    Participant

    Hi I was able to edit my wordpress bar a little bit and add some custom links to it through the custom menu and the Admin Bar Improved plugin; but I want to hide those custom links from non-logged in users and don’t know where to begin. Any help?

Viewing 6 replies - 1 through 6 (of 6 total)
  • @chouf1

    Participant

    @iamdhunt

    Participant

    Thanks but I already understand how to add items to the menu, I’ve already done that. What code do I need to add to hide those menu items from non-logged in users?

    @chouf1

    Participant

    You can use a template conditionnal tag.
    if ( is_user_logged_in() ) :
    your custom menu stuff
    else
    something for non logged user
    endif

    @iamdhunt

    Participant

    Ok sorry but I’m not the best programmer. Using their menu as an example, do you mean something like this:

    ”function add_sumtips_admin_bar_link() {
    global $wp_admin_bar;
    if ( !is_super_admin() || !is_admin_bar_showing() )
    return;
    if ( is_user_logged_in() )
    $wp_admin_bar->add_menu( array(
    ‘id’ => ‘sumtips_link’,
    ‘title’ => __( ‘SumTips Menu’),
    ‘href’ => __(‘http://sumtips.com’),
    ) );
    else
    false;
    endif
    }
    add_action(‘admin_bar_menu’, ‘add_sumtips_admin_bar_link’,25);”

    @chouf1

    Participant

    i’m not a programmer at all, but better try this:
    `function add_sumtips_admin_bar_link() {
    global $wp_admin_bar;
    if ( !is_super_admin() || !is_admin_bar_showing() || is_user_logged_in() )
    $wp_admin_bar->add_menu( array(
    ‘id’ => ‘sumtips_link’,
    ‘title’ => __( ‘SumTips Menu’),
    ‘href’ => __(‘http://sumtips.com’),
    ) );
    endif
    }
    add_action(‘admin_bar_menu’, ‘add_sumtips_admin_bar_link’,25);”`

    @iamdhunt

    Participant

    Wow I made things a lot harder than they should’ve been lol. All I had to do was replace ”!is_super_admin()” with ”!is_user_logged_in()”. Thanks for pointing me in the right direction.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Editing New WordPress Toolbar’ is closed to new replies.
Skip to toolbar