I made a small change to the code Tim Wheatley posted for the "member.php" file as follows..
Add:
PHP Code:
// CUSTOM ADD AUTO LOCATION
$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");
if (!$bbuserinfo['field2']) {
$bbuserinfo['field2'] = ucwords(strtolower($ct_array['COUNTRY_NAME']));
}
// END CUSTOM ADD AUTO LOCATION
Above:
PHP Code:
while ($profilefield=$DB_site->fetch_array($profilefields)) {
$profilefieldname="field$profilefield[profilefieldid]";
With the code Tim had posted, the location would be automatically changed to just the country whenever a user modified their profile. With the change I made though, the location will only be automatically changed if the location field is empty (i.e. the user hasn't filled in a location manually).
In other words, if the user already has something in the location field it won't be changed. If the location field is empty, it will be automatically filled in with the country name.