function _password_policy_add_selected_roles_to_account in Password Policy 7
Adds roles selected for user on form to the user object.
This function has no effect if the form does not have a roles field. For instance, the Password Change Tab password form has no roles field.
Parameters
array $form_state: Form state.
object $account: Custom user object for validating constraints.
1 call to _password_policy_add_selected_roles_to_account()
- _password_policy_get_user_from_form in ./
password_policy.module - Gets from form user for whom password is being validated.
File
- ./
password_policy.module, line 802 - Allows enforcing restrictions on user passwords by defining policies.
Code
function _password_policy_add_selected_roles_to_account(array $form_state, &$account) {
if (isset($form_state['values']['roles'])) {
$rids = array_keys(array_filter($form_state['values']['roles']));
$roles = array_combine($rids, $rids);
$account->roles = $roles;
}
}