Wordpress: Control metabox display state (collapse, show)

You can use the functions below to manipulate the display state of your metaboxes in the edit screen. Calling dd_open_metabox_by_default($postType, $metaBoxID) or dd_close_metabox_by_default($postType, $metaBoxID) will check the current display state of $metaBoxID and restored it to the default, if it is different. Other values are untouched and kept while updating. The metabox ID is the first parameter given in the add_meta_box() function. It can also be found as CSS #id of the metaboxes <div/> container.
/**
* Opens a specified metabox (id) by default for the current user.
* User settings for the specified metabox are reset after reload. Other metabox settings will apply.
*
* @version 1.0
* @author Hendrik Schuster <contact@deviantdev.com>
*
* @param string $postType The (custom_)post_type
* @param int $metaBoxID The distinct metabox id
*/
function dd_open_metabox_by_default( $postType, $metaBoxID ) {
$optionUserID = get_current_user_id();
$optionName = 'closedpostboxes_' . $postType;
$optionValue = get_user_option( $optionName, $optionUserID );
$optionValue = is_array( $optionValue ) ? $optionValue : array();

if( ( $key = array_search( $metaBoxID, $optionValue ) ) !== false ) {
unset( $optionValue[$key] );
update_user_option( $optionUserID, $optionName, $optionValue, true );
}
}

/**
* Closes a specified metabox (id) by default for the current user.
* User settings for the specified metabox are reset after reload. Other metabox settings will apply.
*
* @version 1.0
* @author Hendrik Schuster <contact@deviantdev.com>
*
* @param string $postType The (custom_)post_type
* @param int $metaBoxID The distinct metabox id
*/
function dd_close_metabox_by_default( $postType, $metaBoxID ) {
$optionUserID = get_current_user_id();
$optionName = 'closedpostboxes_' . $postType;
$optionValue = get_user_option( $optionName, $optionUserID );
$optionValue = is_array( $optionValue ) ? $optionValue : array();

if( !in_array( $metaBoxID, $optionValue ) ) {
update_user_option( $optionUserID, $optionName, array_merge( $optionValue, array( $metaBoxID ) ), true );
}
}

There are also some similar but older scripts available I did not checked:

[1] http://wordpress.stackexchange.com/questions/4381/make-custom-metaboxes-collapse-by-default

[2] http://surniaulula.com/2013/05/29/collapse-close-wordpress-metaboxes/

Got some ideas or further advices? Just leave a comment or contact me :)