SHARE
TWEET

Hide Yoast SEO meta box from non-admins

a guest Jan 25th, 2014 50 Never
  1. <?php
  2. /*
  3. Plugin Name: Hide Yoast SEO meta box from non-admins
  4. Version: 1.0
  5. */
  6.  
  7. /**
  8.  * Hide SEO metabox from non-admins
  9.  */
  10. function jp_remove_yoast_metabox() {
  11.  
  12.         // If not admin, remove SEO box
  13.         if ( ! current_user_can( 'administrator' ) ) {
  14.  
  15.                 $post_types = array( 'page', 'post' ); // add any custom post types here
  16.  
  17.                 foreach( $post_types as $post_type ) {
  18.                                 remove_meta_box( 'wpseo_meta', $post_type, 'normal' );
  19.                 }
  20.  
  21.         }
  22. }
  23. add_action( 'add_meta_boxes', 'jp_remove_yoast_metabox', 99 );
RAW Paste Data
Top