I'm simply looking to set certain meta boxes inactive. I know about remove_meta_box() but I only want to make them inactive so that the user is still able to turn them back on from the screen options tab at the top.

I've used the Adminimize plugin (http://wordpress.org/extend/plugins/adminimize/) and it functions the way I was hoping to do it. Based on the user role it deactivates the meta boxes you want but doesn't remove them. Do you know how this plugin does it?

2 Answers 2


There's a default_hidden_meta_boxes filter which allows you to do that. It gets called like so:

$hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen);
  • Hmm. thanks for the reply Denis. Not exactly sure how to use the filter though. For example, what would it look like if I wanted to make the Custom Fields meta box inactive.
    – Joe
    Commented Dec 10, 2010 at 22:10
  • 1
    Dunno. How about finding the function that contains it using your favorite editor's search function and using var_dump() to find out? :-) Commented Dec 10, 2010 at 22:18


sorry i mist it somehow that you stated that you know about "remove_meta_box" function anyway i did a little digging and i looked at the Adminimize plugin and saw how it works and basically it adds a css style="display none;" to that meta box according to the options you set in the options panel using a for each loop to run over all roles so you can do something like this:

function get_all_user_roles() {
    global $wp_roles;

    $user_roles = array();

    if ( isset($wp_roles->roles) && is_array($wp_roles->roles) ) {
        foreach ($wp_roles->roles as $role => $data) {
            array_push($user_roles, $role);
            //$data contains caps, maybe for later use..

    return $user_roles;

// return string The name of the current role
function get_current_user_role() {
    global $wp_roles;
    $current_user = wp_get_current_user();
    $roles = $current_user->roles;
    $role = array_shift($roles);
    return isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : false;

//hook admin CSS
add_action('admin_print_styles', 'meta_box_css_hack');
//the magic happens here
function meta_box_css_hack(){
        $user_roles = get_all_user_roles();
    foreach ($user_roles as $role) {
        //first we check if its curent user 
      if ($role = get_current_user_role()){
       /* each role has it own option in the option database witch is an array that holds the name of the meta-boxes div id. */
        $disabled_metaboxes_post_ = get_option('disable[$role]');
        echo '<style type=text/css">';
        $out = ''
        foreach   ($disabled_metaboxes_post_ as $meta_id)
            $out .= '#'.$meta_id . ', ';
        $out = substr($out,0,-2);
        $out .= ' { display: none !important;} </style>';
        echo $out;

i hope this helps.

  • does not answer the question, the user was looking for a way to "hide" (make inactive) specific metaboxes and not remove them as he clearly stated in the first sentence. Commented Jan 17, 2011 at 20:19
  • sorry about that i fixed it to the right answer for the question presented.
    – Bainternet
    Commented Jan 17, 2011 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.