function rules_condition_user_has_role

Condition user: condition to check whether user has particular roles.

Related topics

1 string reference to 'rules_condition_user_has_role'
rules_user_condition_info in modules/user.rules.inc
Implements hook_rules_condition_info() on behalf of the user module.

File

modules/user.eval.inc, line 15

Code

function rules_condition_user_has_role($account, $roles, $operation = 'AND') {
    switch ($operation) {
        case 'OR':
            foreach ($roles as $rid) {
                if (isset($account->roles[$rid])) {
                    return TRUE;
                }
            }
            return FALSE;
        case 'AND':
            foreach ($roles as $rid) {
                if (!isset($account->roles[$rid])) {
                    return FALSE;
                }
            }
            return TRUE;
    }
}