Skip to content

Snippet: Display only Media Post Meta Tab for Non-Admins

function myprefix_hide_wpex_meta_from_authors( $array, $post ) {

	// Return array if admin
	if ( ! current_user_can( 'administrator' ) ) {
		return $array;
	}

	// Save media tab
	$media_tab = $array['media'];
	
	// Remove all settings
	$array = array();

	// Re-add media tab settings
	$array['media'] = $media_tab;

	// Return fields
	return $array;

}
add_filter( 'wpex_metabox_array', 'myprefix_hide_wpex_meta_from_authors', 40, 2 );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top