WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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.

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
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

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