function restrict_by_ip_login_add_edit_user_submit 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_submit()
Submit function for add/edit new login IP restriction form.
File
- ./
restrict_by_ip.module, line 302 - 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_submit($form, &$form_state) {
$uid = db_query("SELECT uid FROM {users} WHERE name = :name", array(
':name' => $form_state['values']['name'],
))
->fetchField();
// Remove any existing settings
db_query("DELETE FROM {restrict_by_ip} WHERE uid = :uid", array(
':uid' => $uid,
));
// Insert new settings
if (strlen($form_state['values']['restriction']) > 0) {
db_query("INSERT INTO {restrict_by_ip} (uid, restrict_by_ip_address) VALUES (:uid, :ip)", array(
':uid' => $uid,
':ip' => $form_state['values']['restriction'],
));
}
drupal_set_message("User restriction has been saved.");
}