function rules_action_user_add_role

Action: Adds roles to a particular user.

Related topics

1 string reference to 'rules_action_user_add_role'
rules_user_action_info in modules/user.rules.inc
Implements hook_rules_action_info() on behalf of the user module.

File

modules/user.eval.inc, line 45

Code

function rules_action_user_add_role($account, $roles) {
    if ($account->uid || !empty($account->is_new)) {
        // Get role list (minus the anonymous).
        $role_list = user_roles(TRUE);
        foreach ($roles as $rid) {
            $account->roles[$rid] = $role_list[$rid];
        }
        if (!empty($account->is_new) && $account->uid) {
            // user_save() inserts roles after invoking hook_user_insert() anyway, so
            // we skip saving to avoid errors due saving them twice.
            return FALSE;
        }
    }
    else {
        return FALSE;
    }
}