Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Control Edit Post meta box display WordPress

  • SOLVED

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.

Also, is there a function to collapse certain meta boxes and leave others open. I would like to focus the users attention to the important meta boxes by collapsing the others.


<EDIT>

I found the filter to use... default_hidden_meta_boxes but not sure how to do it. Using this how would I deactivate the custom fields meta box?

$hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen);

Answers (3)

2010-12-19

Buzu B answers:

Joe Asked me to take a look at his problem. I sent him a solution.

2010-12-10

Bob answers:

I have looked around and I do not think there is any "easy" way to accomplish this. As you said already it fairly easy to turn them off or on, but to have a dynamic option in the admin for users would require writing your own plugin.

You can auto collapse the meta box's based on user role which would probably be a better idea. The opening or closing of the meta box's is controlled by an ajax call.

You can see a reference for it in this post at the bottom under javascript
[[LINK href="http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins"]]http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins[[/LINK]]

And here is a function that does what your asking for, I will just link to it because it requires explanation.
[[LINK href="http://wordpress.stackexchange.com/questions/4381/make-custom-metaboxes-collapse-by-default"]]http://wordpress.stackexchange.com/questions/4381/make-custom-metaboxes-collapse-by-default[[/LINK]]


Joe Calithia comments:

Hmm. 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?


Joe Calithia comments:

I found the filter to use... default_hidden_meta_boxes but not sure how to do it. Using this how would I deactivate the custom fields meta box?

$hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen);

2010-12-16

Rashad Aliyev answers:

Hello,

It must be on here: wp-admin/includes/template.php Look at this.


http://core.trac.wordpress.org/attachment/ticket/14212/14212.diff