基于this Answer by t31os.
这里,所有的元框都被设置为不可见,所以只需从数组中删除那些应该可见的元框即可。
add_action(\'user_register\', \'wpse_58645_set_user_metaboxes\');
function wpse_58645_set_user_metaboxes( $user_id )
{
update_user_meta(
$user_id,
\'metaboxhidden_post\',
array(
\'authordiv\',
\'categorydiv\',
\'commentstatusdiv\',
\'formatdiv\',
\'postcustom\',
\'postexcerpt\',
\'postimagediv\',
\'slugdiv\',
\'tagsdiv-post_tag\',
\'trackbacksdiv\',
)
);
}
对于注册用户,运行
admin_init
只能做一次,但这只是一个概念:
$blogusers = get_users(\'blog_id=1\');
foreach ( $blogusers as $user )
{
if ( !get_user_meta( $user->ID, \'metaboxhidden_post\', true ) )
{
update_user_meta( $user->ID, \'metaboxhidden_post\', $meta_value );
}
}