WordPress Trick: Hide Admin Panels From Specific User Roles

When you’re building a WordPress website for a client, sometimes you’ll want to hide certain admin panels from specific user roles; do editors really need “custom fields”? Drop the following code into your functions.php file to hide the Custom Fields meta-box from editors.

function hide_meta_boxes() {
     remove_meta_box('postcustom','post','normal');
     remove_meta_box('postcustom','page','normal');
}

if (!current_user_can('manage_options')) {
	add_action('admin_init','hide_meta_boxes');
}

The remove_meta_box function takes three parameters. 1: the div ID of the box you want to hide, the context (post or page) and position (normal or advanced).