function restrict_by_ip_login_add_edit_user_validate in Restrict Login or Role Access by IP Address 7.3
Same name and namespace in other branches
- 6.3 restrict_by_ip.module \restrict_by_ip_login_add_edit_user_validate()
Validation function for add/edit login IP restriction form.
File
- ./
restrict_by_ip.module, line 285 - Allows the admin to select which ip addresses role or a user can login from for this site Some of the code below is taken from the cck_ipaddress_module
Code
function restrict_by_ip_login_add_edit_user_validate($form, &$form_state) {
// Check for valid user
$uid = db_query("SELECT uid FROM {users} WHERE name= :name", array(
':name' => $form_state['values']['name'],
))
->fetchField();
if (!$uid) {
form_set_error('name', t('Invalid user.'));
}
if (strlen($form_state['values']['restriction']) > 0) {
$ret = _restrict_by_ip_validate_ip($form_state['values']['restriction']);
if ($ret['result'] == FALSE) {
form_set_error('restriction', t(implode('<br />', $ret['messages'])));
}
}
}