Drupal Conditional PHP if admin or user has certain role
问题 The following will do 'something' if the user is admin. <?php if (($is_admin)) : ?> do something <?php endif; ?> How can I change this so 'something' will happen if the user is admin or has a certain role? Thanks 回答1: Roles are stored in $user->roles . To check "if the user is admin or has a certain role" you can simply: if ($is_admin || in_array('some_role', $user->roles)): 回答2: For checking if the user belongs to one or more roles, you can do: global $user; $allowed_roles = array('customer'