Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Editing New WordPress Toolbar

  • Avatar of iamdhunt
    iamdhunt
    Participant

    @iamdhunt

    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)
  • Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

    Avatar of iamdhunt
    iamdhunt
    Participant

    @iamdhunt

    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?

    Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

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

    Avatar of iamdhunt
    iamdhunt
    Participant

    @iamdhunt

    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);”

    Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

    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);”`

    Avatar of iamdhunt
    iamdhunt
    Participant

    @iamdhunt

    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)

You must be logged in to reply to this topic.