It didn’t say in the API docs on the Yoast SEO plugin site what the ID
was and I don’t have a copy of Yoast at installed at disposal, but according to yoas-plugin-dir/admin/class-metabox.php
line 144, the meta_box registered is;
add_meta_box( 'wpseo_meta', ...etc ); ...
Which is hooked onto add_meta_boxes
hook on line 32 of the same file,
add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
Of course you could get the ID from the meta box itself on the post edit screen… Anyway.
You can do the following,
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');
}
}
…where post type is the post type you wish to apply this restriction too, such as post
or a custom post type one or more!
Should do the trick.
update: manage_plugins
should have been activate_plugins
– ammended.