[Resolved] Editing New WordPress Toolbar
-
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?
-
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?
You can use a template conditionnal tag.
if ( is_user_logged_in() ) :
your custom menu stuff
else
something for non logged user
endifOk 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);”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);”`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.
- The topic ‘[Resolved] Editing New WordPress Toolbar’ is closed to new replies.