Skip to content

Instantly share code, notes, and snippets.

@jdhobbsuk
Created December 10, 2015 15:30
Show Gist options
  • Save jdhobbsuk/a9fa809e679843c01acd to your computer and use it in GitHub Desktop.
Save jdhobbsuk/a9fa809e679843c01acd to your computer and use it in GitHub Desktop.
By default, users don't have excerpts displayed in the admin...this forces it.
// Force Page CPT to have excerpt (all users)
// -------------------------------------------------------------
if ( is_admin() ) :
function force_excerpt_box() {
// get all post types (excluding posts)
$post_types = array('page');
// get all users
$all_users = get_users( );
$user_list = array();
$hide_boxes = array(
'postcustom',
'trackbacksdiv',
'commentstatusdiv',
'commentsdiv',
'slugdiv',
'authordiv',
'revisionsdiv',
);
foreach($all_users as $user):
$user_list[] = $user->id;
endforeach;
foreach($user_list as $user):
foreach($post_types as $post_type):
update_user_option($user, 'metaboxhidden_'.$post_type, $hide_boxes);
endforeach;
endforeach;
update_user_option(1, 'metaboxhidden_page', $hide);
}
add_action( 'admin_menu', 'force_excerpt_box' );
endif;
@jdhobbsuk
Copy link
Author

New users are created with certain admin settings pre-set...this includes not seeing the Page's excerpt in the admin. This forces all users to have certain box settings hidden, excluding the excerpt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment