function userprotect_user_edit_fields_validate in User protect 6
Same name and namespace in other branches
- 5 userprotect.module \userprotect_user_edit_fields_validate()
- 7 userprotect.module \userprotect_user_edit_fields_validate()
Custom validation function for complex field protections.
1 string reference to 'userprotect_user_edit_fields_validate'
- userprotect_form_alter in ./
userprotect.module - Alters forms for user protection.
File
- ./
userprotect.module, line 299
Code
function userprotect_user_edit_fields_validate($form, &$form_state) {
$account = $form_state['userprotect']['account'];
$field = $form_state['userprotect']['field'];
switch ($field) {
case 'roles':
// Authenticated user isn't a valid checked item.
unset($account->roles[DRUPAL_AUTHENTICATED_RID]);
// Add values for all role checkboxes that are valid roles for this user.
foreach ($account->roles as $rid => $role) {
if (isset($form[$rid])) {
form_set_value($form[$rid], 1, $form_state);
}
}
break;
}
}