function restrict_by_ip_user in Restrict Login or Role Access by IP Address 6.3
Same name and namespace in other branches
- 5 restrict_by_ip.module \restrict_by_ip_user()
- 6 restrict_by_ip.module \restrict_by_ip_user()
- 6.2 restrict_by_ip.module \restrict_by_ip_user()
Implementation of hook_user().
File
- ./
restrict_by_ip.module, line 103 - 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_user($type, &$edit, &$account, $category = NULL) {
switch ($type) {
case 'login':
_restrict_by_ip_login($account);
break;
case 'insert':
if (strlen($edit['restrict_by_ip_address']) > 0) {
// If an IP restriction is set, add it to database
db_query("INSERT INTO {restrict_by_ip} (uid, restrict_by_ip_address) VALUES (%d, '%s')", $edit['uid'], $edit['restrict_by_ip_address']);
}
break;
case 'delete':
// Delete any IP restrictions for users upon account deletions
if ($account->uid != 0) {
db_query("DELETE FROM {restrict_by_ip} WHERE uid=%d", $account->uid);
}
break;
}
}