I also made the following change so no user can leave the location field empty in their profile..
In "root/member.php" find:
PHP Code:
// check extra profile fields
$userfields="";
$profilefields=$DB_site->query("SELECT profilefieldid,required,title,size,maxlength
FROM profilefield
WHERE editable = 1");
And Add Below It:
PHP Code:
// CUSTOM ADD AUTO LOCATION
if (!$field2) {
$ip_number = sprintf("%u",ip2long($REMOTE_ADDR));
$ct_array = $DB_site->query_first("SELECT COUNTRY_NAME FROM ip2country WHERE $ip_number >= IP_FROM AND $ip_number <= IP_TO LIMIT 1");
$field2 = ucwords(strtolower($ct_array['COUNTRY_NAME']));
}
// END CUSTOM ADD AUTO LOCATION
In "root/register.php" find:
PHP Code:
// check extra profile fields
$userfields="";
$userfieldsnames="(userid";
$profilefields=$DB_site->query("SELECT maxlength,profilefieldid,required,title
FROM profilefield
WHERE editable = 1
ORDER BY displayorder");
And Add Below It:
PHP Code:
// CUSTOM ADD AUTO LOCATION
if (!$field2) {
$ip_number = sprintf("%u",ip2long($REMOTE_ADDR));
$ct_array = $DB_site->query_first("SELECT COUNTRY_NAME FROM ip2country WHERE $ip_number >= IP_FROM AND $ip_number <= IP_TO LIMIT 1");
$field2 = ucwords(strtolower($ct_array['COUNTRY_NAME']));
}
// END CUSTOM ADD AUTO LOCATION
With these additions, if a user leaves the location field empty (either when registering or updating their profile), the country will be automatically inserted into the database. Resulting in no empty locations.