You are here

function smart_ip_user_presave in Smart IP 7

Same name and namespace in other branches
  1. 7.2 smart_ip.module \smart_ip_user_presave()

Implements hook_user_presave().

Detects IP and geo location upon registration.

File

./smart_ip.module, line 210
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();

    // 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'];
  }
}