最好将您的资产包括在admin_enqueue_scripts
回答你的问题
add_action(\'admin_head\', \'grup_custom_admin_post_css\');
function grup_custom_admin_post_css()
{
$allow_post_types = array(\'custom_role\', \'custom_role_2\', \'etc\');
$allow_roles = array(\'post_type\', \'post_typ_2\');
$current_user = wp_get_current_user();
if (array_intersect($current_user->roles, $allow_roles)) { // do something if user have one of these roles
global $post_type;
if ($post_type && in_array($post_type, $allow_post_types)) {
echo "<style></style>";
}
}
}