configuration['rid']; // Skip adding the role to the user if they already have it. if ($account !== FALSE && !$account->hasRole($rid)) { // For efficiency manually save the original account before applying // any changes. $account->setOriginal(clone $account); $account->addRole($rid)->save(); } } }