Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Hide Yoast SEO meta box from non-admins

By: a guest on Jan 25th, 2014  |  syntax: PHP  |  size: 0.50 KB  |  views: 40  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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 );