max-kk
11/26/2016 - 11:48 AM

Wordpress :: Remove (hide) meta boxes from Post editing from non admin's (Comments, Slug, Categories) + Yoast Seo + Revolution slider

Wordpress :: Remove (hide) meta boxes from Post editing from non admin's (Comments, Slug, Categories) + Yoast Seo + Revolution slider

<?php

function wpse605901_remove_metaboxes() {
	if ( !current_user_can('manage_options') ) {
	    remove_meta_box( 'categorydiv' , 'post' , 'normal' ); 
	    remove_meta_box( 'formatdiv' , 'post' , 'normal' ); 
	    remove_meta_box( 'um-admin-access-settings' ); 
	    remove_meta_box( 'tagsdiv-post_tag' , 'post' , 'normal' ); 

	    remove_meta_box( 'trackbacksdiv' , 'post' , 'normal' ); 
	    remove_meta_box( 'postcustom' , 'post' , 'normal' ); 
	    remove_meta_box( 'commentstatusdiv' , 'post' , 'normal' ); 
	    remove_meta_box( 'slugdiv' , 'post' , 'normal' ); 
	}

}
add_action( 'admin_menu' , 'wpse605901_remove_metaboxes', 999 );

function do_meta_boxes_remove_metaboxes() {
	if ( !current_user_can('manage_options') ) {
	    remove_meta_box( 'mymetabox_revslider_0', 'page', 'normal' );
	    remove_meta_box( 'mymetabox_revslider_0', 'post', 'normal' );
	    remove_meta_box('wpseo_meta', 'post', 'normal');
	}

}
add_action( 'do_meta_boxes' , 'do_meta_boxes_remove_metaboxes', 999 );