The latest version of WordPress hides a number of metaboxes by default.
On nav-menus.php (Appearance > Menus) I would like the 'Posts' (Screen Options > Posts) and 'Description' (Screen Options > Description) features checked/shown by default for all new users. Please can someone suggest a simple function that updates a users profile to show 'Posts' and a menu items 'Description' by default on the menu builder page.
Maybe have a look at [[LINK href="http://wordpress.stackexchange.com/questions/15376/how-to-set-default-screen-options"]]http://wordpress.stackexchange.com/questions/15376/how-to-set-default-screen-options[[/LINK]] and in particular Rarst's default_hidden_meta_boxes filter suggestion as this may provide a starting point.
Many thanks
Ross Wilson answers:
Looks like the function you want to replace is not pluggable, and isn't wrapped in a function_exists. The options are to wrap it in the core code and include your own in functions.php, or set the defaults when a user is created. Let me know which way you want to go and I can help you out.
Ross Wilson comments:
After some testing I think this is the best option. This will set the default meta boxes when a user is registered. Add this to your functions.php.
add_action( 'user_register', 'set_user_menus');
function set_user_menus($userid){
update_user_option( $userid, 'metaboxhidden_nav-menus', array('add-post_tag'), true );
update_user_option( $userid, 'managenav-menuscolumnshidden', array('link-target', 'css-classes', 'xfn'), true);
}
designbuildtest comments:
Hi Ross, thanks for your response.
I'd have to be guided by your superior experience about which approach would be better/easier/safer to take unfortunately. I don't want to be changing any core files and it would be great if the solution could be applied via my functions.php file.
I currently use the below function to show the post excerpt by default on edit.php if this helps at all...
add_filter('default_hidden_meta_boxes', 'be_hidden_meta_boxes', 10, 2);
function be_hidden_meta_boxes($hidden, $screen) {
if ( 'post' == $screen->base )
// Resets all Post Screen Options hidden by default
$hidden = array('slugdiv');
return $hidden;
}
Thanks
designbuildtest comments:
Hi Ross, I just posted as you did the same... I'll go try your proposed solution now. Cheers.
Ross Wilson comments:
Yah, unfortunately the menu page doesn't use the default_hidden_meta_boxes filter, it uses another function entirely, wp_initial_nav_menu_meta_boxes, which has the default meta boxes hard coded in it.
designbuildtest comments:
Gidday Ross, your solution worked a treat - exactly what I needed - cheers.