If you want to hide all the metaboxes for all users, you can do that through the get_user_option_metaboxhidden_{cpt}
, default_hidden_meta_boxes
or the hidden_meta_boxes
filter, according to the /wp-admin/includes/screen.php
file.
Here’s an example for the post
post type:
/**
* Hide all metaboxes in the global $wp_meta_boxes
*/
add_filter( 'hidden_meta_boxes', function( $hidden, $screen, $use_defaults )
{
global $wp_meta_boxes;
$cpt="post"; // Modify this to your needs!
if( $cpt === $screen->id && isset( $wp_meta_boxes[$cpt] ) )
{
$tmp = array();
foreach( (array) $wp_meta_boxes[$cpt] as $context_key => $context_item )
{
foreach( $context_item as $priority_key => $priority_item )
{
foreach( $priority_item as $metabox_key => $metabox_item )
$tmp[] = $metabox_key;
}
}
$hidden = $tmp; // Override the current user option here.
}
return $hidden;
}, 10, 3 );