function smart_ip_user_presave in Smart IP 7.2
Same name and namespace in other branches
- 7 smart_ip.module \smart_ip_user_presave()
Implements hook_user_presave().
Save new user's geolocation upon registration.
File
- ./
smart_ip.module, line 246 - Determines country, geo location (longitude/latitude), region, city and postal code of the user, based on IP address
Code
function smart_ip_user_presave(&$edit, $account, $category) {
if ($account->is_new == TRUE && variable_get('smart_ip_save_user_location_creation', TRUE)) {
// Successful registration. First determine user's location based on IP
$location = smart_ip_get_current_visitor_location_data();
// Determine if saving location details of visitor from EU countries are
// permitted.
$eu_visitor_dont_save = FALSE;
if (isset($location['is_gdpr_country'])) {
$eu_visitor_dont_save = variable_get('smart_ip_eu_visitor_dont_save', FALSE) && $location['is_gdpr_country'];
}
if (!$eu_visitor_dont_save) {
// Store the location information in the $user object
smart_ip_set_session_data($location);
$smart_ip_session = smart_ip_session_get('smart_ip');
$edit['data']['geoip_location_original'] = $smart_ip_session['location'];
}
}
}