1

I've a problem with permission. Is there a specific permission to let an user with Editor Role, manage the custom menu of a theme, and only this options?

The item that is under Appereance -> Menu, to be clear.

I'm using the capability plugin. Must I write a custom hook to enable only the use of custom menu editor ?

TIA

Edit: I've code a simple solution. See below my answer!

2 Answers 2

1

You need to give the editor role the 'edit_theme_options' permission, but that will also unlock other theme options like widgets to those users.

1
  • Yes, true. This was what I did. This is not exactly what I need. Thanks. I'll try to write a custom hook...
    – keatch
    Feb 3, 2011 at 13:54
1

Ok, I've found a way, using the admin_menu action. I post here, in case someone needs it.

This code remove for a specific user all the submenus items except the one for the custom menus in the Appereance menu.

add_action('admin_menu', 'enable_only_custom_menu');

function enable_only_custom_menu() {
    global $menu,$submenu;
    global $current_user;
    get_currentuserinfo();

    if ($current_user->user_login == 'username') {
        foreach($submenu['themes.php'] as $key=>$smenu) {
            if ($smenu[2] != 'nav-menus.php') {
                unset($submenu['themes.php'][$key]);
            }
        }
    }
}

You must iterate the submenu for the key 'themes.php' and deleting all the items that are not interisting for you.

2
  • Unsetting the menu item may literally stop the user accessing a given page, but that doesn't necessarily mean they can't perform a given action. I'm thinking out loud here, but i'd suggesting looking at $wp_post_types and tweaking the nav menu post-type. When i say tweak i mean hook in and swap out the required capabilities for that type with custom ones(then you can assign those caps as you choose).
    – t31os
    Feb 4, 2011 at 0:21
  • ..following on... Nav menus are post types, so like any other post type they have a set of capabilities required to manage them, hooking in at an appropriate point might provide a means for tweaking the capabilities required to manage that post type(custom caps, or whatever).
    – t31os
    Feb 4, 2011 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.