Skip to content

Instantly share code, notes, and snippets.

@wpspeak
Last active December 26, 2015 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpspeak/7184298 to your computer and use it in GitHub Desktop.
Save wpspeak/7184298 to your computer and use it in GitHub Desktop.
Remove default metabox in post editor from non-admins.
<?php
function afn_remove_post_metabox() {
if( !current_user_can('manage_options') ) {
remove_meta_box( 'postexcerpt', 'post', 'normal' ); // Excerpt Metabo
remove_meta_box( 'trackbacksdiv', 'post', 'normal' ); // Trackback Metabox
remove_meta_box( 'postcustom', 'post', 'normal' ); // Custom Fields Metabox
remove_meta_box( 'commentstatusdiv', 'post', 'normal' ); // Comments Status Metabox
remove_meta_box( 'commentsdiv', 'post', 'normal' ); // Comments Metabox
remove_meta_box( 'revisionsdiv', 'post', 'normal' ); // Revisions Metabox
remove_meta_box( 'authordiv', 'post', 'normal' ); // Author metabox
remove_meta_box( 'slugdiv','post','normal' ); // Slug Metabox
remove_meta_box( 'tagsdiv-post_tag','post','side' ); // Tags metabox
remove_meta_box( 'submitdiv','post','side' ); // Date, status, and update/save metabox
remove_meta_box( 'categorydiv','post','side' ); // Categories metabox
remove_meta_box( 'postimagediv','post','side'); // Featured image metabox
}
}
add_action( 'admin_menu', 'afn_remove_post_metabox' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment