I have found these two filters, that can be used to keep post meta boxes closed by default. However, this works for Yoast SEO because the $box_id = wpseo_meta is available, but there is no $box_id for this plugin?
add_filter( 'get_user_option_closedpostboxes_page', function( $closed, $option, $user ) {
$closed[] = 'wpseo_meta';
return $closed;
}, 10, 3 );
// OR with this filter
add_filter( "postbox_classes_page_wpseo_meta", function( $classes ) {
$classes[] = 'closed';
return $classes;
}, 10, 1 );
They will work on pages only here, but can be on posts or cpt by switching screen_id and box_id postbox_classes_{$screen_id}_{$box_id} and get_user_option_closedpostboxes_{$screen_id}
-
This reply was modified 4 years, 11 months ago by
Vayu Robins.
Hi @vayu
The ID of the meta box is members-cp, so can try to use this in your code and see if that helps?
Best
Thanks @caseproof!
This works:
add_filter( 'get_user_option_closedpostboxes_page', function( $closed, $option, $user ) {
$closed[] = 'members-cp'; // Members plugin
return $closed;
}, 10, 3 );