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.

have spent half an hour hunting around on Google to solve this so any ideas greatly appreciated!


I'm using a bought theme running wp3.2 and the theme includes a few extra features Testimonials, Portfolio and Slider (they show in the admin, but aren't plugins)

I'm comfortable using $role_objet->remove_cap(); in the funtions.php file to manage capabilities, but I'm not sure how to reference these features.

Basically I'm want to hide these menu items off for Editors.

share|improve this question
add comment

2 Answers 2

If what you want to do is to hide the menu items you can make use of remove_menu_page and remove_submenu_page by hooking into admin_menu.

In order to hide certain links based on the user's role (in your case, Editor):

function custom_remove_menus(){

    // Get current user's data
    $current_user = wp_get_current_user();
    $user_id = $current_user->ID;

    // Check user's roles   
    $user = new WP_User( $user_id );
    if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
        if( in_array( 'editor', $user->roles ) ) {
            // Remove menu items
            remove_menu_page( 'edit.php?post_type=news' );
            remove_submenu_page( 'edit.php?post_type=news', 'post-new.php?post_type=news');
        }
    }
}

add_action( 'admin_menu', 'custom_remove_menus' );

You can hover over the menus to see what the link is.

However, as noted in the Codex

Please be aware that this would not prevent a user from accessing these screens directly. Removing a menu does not replace the need to filter a user's permissions as appropriate.

share|improve this answer
add comment

If the theme is coded the right way then these features should by default only be available to users with manage_themes capability and that capabilty is not given to editors by default.

share|improve this answer
add comment

Your Answer

 
discard

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

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