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.

Possible Duplicate:
WordPress SEO by Yoast: Hide Meta boxes in posts for non-admins

I was wondering how to remove Meta-boxes from the post page. I would like that only administrators or editors could see these. I saw similar topics on the forum, but none of them appears to be working. Any suggestions?

share|improve this question
add comment

marked as duplicate by userabuser, kaiser, Wyck, brasofilo, toscho Oct 30 '12 at 19:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

See WordPress SEO by Yoast: Hide Meta boxes in posts for non-admins

add_action('add_meta_boxes', 'yoast_is_toast', 99);
function yoast_is_toast(){
    //capability of 'manage_plugins' equals admin, therefore if NOT administrator
    //hide the meta box from all other roles on the following 'post_type' 
    //such as post, page, custom_post_type, etc
    if (!current_user_can('activate_plugins')) {
        remove_meta_box('wpseo_meta', 'post_type', 'normal');
    }
}
share|improve this answer
    
Should I replace code in Line 32: add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) ); with this? –  user23076 Oct 30 '12 at 16:59
1  
No... you need to only add the function snippet above to your functions.php file, nothing else, except change post_type to your required type i.e. post. The references to line numbers in the other answer only explain whats in the plugin file itself for reference on where I sourced further information. Normally you would just get the name of the metabox from the ID parameter on the edit screen. I didnt have yoast installed at time, so I just dug into plugin files –  userabuser Oct 30 '12 at 17:00
add comment

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