Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Hey. I've been trying to figure this out for a long time but can't seem to crack it.

I have created a menu using Wordpress 3 menu editor and it's all fine and working.

But I want to manually add an item (or few) to a submenu so that the item will only show up in the submenu if logged in user is admin (can add_users).

How can I achieve this?

I already came up with a solution of having two separate menus for another purpose. But that is not what I want in this case.

Say I have a menu called "Archives" It has a submenu with items "One" "Two" "Three". This I have built using the Wordpress menu system.

Now I want to manually add a new item to the Archives menu, let's call it "Four" but I only want this to appear in the menu when a user is logged in and is admin.

@MikeSchinkel - still haven't figured this one out... if you know, could you help me out?

Thanks!

share|improve this question
add comment

2 Answers

the simplest way would be to create two menus on for admin and one for everyone else and display them based on that:

if (current_user_can('add_users')){
   wp_nav_menu( array('menu' => 'My Admin Menu' ));
}else{
   wp_nav_menu( array('menu' => 'My Users Menu' ));
}
share|improve this answer
add comment

Hi @fusse:

If you want the menu to be added only for an admin then really want you want is to be able to do is to remove the menu item for non-admin users?

Before I can continue, can I confirm that is what you want?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.