merefield
(Robert)
December 27, 2025, 7:29pm
1192
This plugin remains unfunded, so its future is in some doubt, however, for the time being I have added the following:
main ← fix_user_location_storage_and_retrieval
merged 10:28AM - 27 Dec 25 UTC
@viddekla that should resolve your issue
main ← add_national_flags
merged 03:21PM - 27 Dec 25 UTC
* By default, location labels for users will now show the national flag related … to their location. You can disable these with plugin setting `location_user_country_flag `
* Maps for single users are now bigger
main ← quick_find_current_location
merged 07:11PM - 27 Dec 25 UTC
If you think Locations is awesome and I did a great job here, you can buy me a coffee
5 Likes
merefield
(Robert)
December 28, 2025, 12:36pm
1193
I should add the new quick find current location target button on the location selector works for Topic locations too if you disable location input fields.
Just needs a tweak to styling …
main ← location_selector_styling_tweaks
merged 01:11PM - 28 Dec 25 UTC
4 Likes
merefield
(Robert)
December 28, 2025, 6:23pm
1194
Important bug fix, please update:
main ← fix_double_encoding
merged 06:04PM - 28 Dec 25 UTC
* New User locations were being double encoded into JSON
* Re-entering them wil… l fix data issues.
(only impacts user locations entered since this weekends patch, simply enter them again)
4 Likes
Nice work! I’m seeing an additional broken flag below the username, any idea why?
2 Likes
Moin
January 4, 2026, 7:31am
1196
Makes me think this is from the Locations Plugin 🌍 .
main ← add_national_flags
merged 03:21PM - 27 Dec 25 UTC
* By default, location labels for users will now show the national flag related … to their location. You can disable these with plugin setting `location_user_country_flag `
* Maps for single users are now bigger
5 Likes
merefield
(Robert)
January 4, 2026, 3:21pm
1197
Yes, you no longer need to run both. In the Locations Plugin , it is trivial to determine the country code, so why not offer a flag to go with it?
3 Likes
RGJ
(Richard - Communiteq)
January 4, 2026, 3:51pm
1198
davidkingham:
broken flag
You should lowercase the country code @merefield
2 Likes
merefield
(Robert)
January 4, 2026, 4:00pm
1199
Country codes out of the box in Locations are lower case. Perhaps it relates to a third party data provider.
I offer paid support if someone needs me to take a closer look or PR welcome.
That is the issue, I changed it to lowercase manually and it loaded. Tried Mapquest and Mapbox with same results. I’ll shoot you a PM Rob.
2 Likes
gilles
January 8, 2026, 8:55pm
1202
Hello, thank you for this plugin which is great
I am trying to display the name of my subject on the map because I only have the location
Is there a parameter to activate?
Thank you
1 Like
merefield
(Robert)
January 12, 2026, 10:17pm
1203
Some updates:
@Renato kindly fixed an issue on Category settings:
main ← renato:modernize_available_views
merged 09:48PM - 12 Jan 26 UTC
Uses the existing value transformer instead of a modifyClass.
We had a contribution for the Russian language, thank you!
main ← replaid:patch-1
merged 09:51PM - 12 Jan 26 UTC
* Completed translation of client.ru.yml to the Russian language.
* Used a neut… ral, public address in a Russian-speaking country that is not part of a conflict.
Existing file's translation is incomplete, and its example address uses the English-language version's Sydney address but states its city as Киев.
And finally I added an experimental new Topic List filter called Nearby:
main ← add_nearby_filter
merged 11:08PM - 11 Jan 26 UTC
* FEATURE: adds a "Nearby" Topic List filter if new setting `location_nearby_lis… t_max_distance_km` is non-zero and user has a geo location recorded.
* FIX: makes the location selector work for topic selection on Modals
Which lists all the Topics within x km (setting) from the logged in user’s supplied location.
@Barney_Lodge that was inspired by your use case and took up most of my Sunday
This also fixes the inline location selector for Topics on the modal.
8 Likes
Oh wow!!! I am loving Discourse !!
Regards
Barney Lodge
3 Likes
merefield
(Robert)
January 13, 2026, 12:24pm
1205
In a past but recent release there was a bug in the UserLocation population logic. That is now fixed, but there may be some data impact.
This doesn’t currently affect much but may affect the map in the future.
You can identify if you have the problem by running this on the rails console:
array_for_fix = Locations::UserLocation.where(state: "state").pluck(:user_id)
if that’s not empty, simply run this:
array_for_fix.each do |id|
Locations::UserLocationProcess.upsert(id)
end
The other way this can be fixed is manually re-entering the user map location, so basically future user location edits will simply overwrite the bad data.
Apologies for the inconvenience.
If anyone wants to write a migration or rake task, PR welcome.
6 Likes
祁同伟
January 20, 2026, 1:39am
1206
Is it possible to implement this feature:
After a user publishes a thread or reply, automatically detect the location based on their current IP address and display it below their avatar in the thread/post—instead of requiring users to manually select it or set it in their profile.
I am willing to provide paid support for this.
Just like ZHIHU.
1 Like
merefield
(Robert)
January 20, 2026, 7:12am
1207
Involuntary update of user location would be a big departure for this plugin as to date it’s been reliant on voluntary submission and therefore individual user buy-in.
But I can see the case for it. It would make gathering user location much more reliable and less dependent on user action.
There’s already a Post label for user location on every Post. So I think this part is already covered.
I think automated update of user location as a site option during posting is feasible and reasonable so long as:
Sites update their T&C’s
The location is sufficiently approximate, perhaps to the nearest city? To me tracking people to the street is unlikely to endear users to the site! Perhaps you’d want an option to set granularity to city, province (if generally feasible via data) or country. I’d be interested in other admin’s opinions about this.
It would be optimal if we could standardise on MaxMind, which is the standard IP Geolocation service native to Discourse core.
I would be happy to consider sponsorship to add back end automation as a site option. I’ll contact you via PM to see if we can reach agreement.
4 Likes
祁同伟
January 20, 2026, 7:21am
1208
City-level precision is sufficient. Street-level precision would be terrifying.
4 Likes
nathank
(Nathan Kershaw)
January 20, 2026, 2:04pm
1209
Having a granularity option as a site default would be brilliant. As would the ability of the users to alter the granularity / opt out.
2 national forums I run would be great for province granularity. A local one would be great for suburb granularity.
I can easily imagine sites using all the options.
3 Likes
Roi
January 26, 2026, 2:37pm
1210
merefield:
You can identify if you have the problem by running this on the rails console:
array_for_fix = Locations::UserLocation.where(state: "state").pluck(:user_id)
if that’s not empty, simply run this:
array_for_fix.each do |id|
Locations::UserLocationProcess.upsert(id)
end
Thank you, I ran this and it found something:
discourse(prod)> array_for_fix = Locations::UserLocation.where(state: "state").pluck(:user_id)
=> [175, 12, 578, 1347, 1355, 1, 590]
discourse(prod)* array_for_fix.each do |id|
discourse(prod)* Locations::UserLocationProcess.upsert(id)
discourse(prod)> end
=> [175, 12, 578, 1347, 1355, 1, 590]
Then I ran the first command again and it still found 590, which also did not vanish when I ran the second command:
discourse(prod)> array_for_fix = Locations::UserLocation.where(state: "state").pluck(:user_id)
=> [590]
discourse(prod)* array_for_fix.each do |id|
discourse(prod)* Locations::UserLocationProcess.upsert(id)
discourse(prod)> end
=> [590]
What can I do?
merefield
(Robert)
January 31, 2026, 2:30pm
1211
Delighted to announce that both @祁同伟 and @nathank have stepped up to sponsor the work for setting user location via IP
This work will be experimental for a while, but I’m also delighted to tell you the PR is already up here:
main ← automated_ip_based_user_location_determination
opened 02:16PM - 31 Jan 26 UTC
## IP‑based User Location (MaxMind → GeoNames)
### What this adds
- Auto… matically determines a user’s location from their IP after post creation.
- Uses **MaxMind (DiscourseIpInfo)** for identity + GeoNames for canonical lat/lon.
- Stores exactly **one granularity level** per user (`country` / `province` / `city`) in `UserCustomField`
`geo_location`.
- Ensures lat/lon match the chosen granularity (privacy‑correct coordinates).
- Caches GeoNames lookups by `geoname_id` (no extra gems; uses `FinalDestination::HTTP`).
---
## Prerequisites (official accounts)
You must have valid accounts and credentials from:
- **MaxMind GeoLite2**
Sign up and obtain an Account ID + License Key:
https://www.maxmind.com/en/geolite2/signup
- **GeoNames**
Create a username for the GeoNames API and **enable Web Services** in your GeoNames account settings:
https://www.geonames.org/login
---
## Required Configuration
**Env vars (MaxMind)**
- `DISCOURSE_MAXMIND_ACCOUNT_ID`
- `DISCOURSE_MAXMIND_LICENSE_KEY`
**Site settings**
- `location_geonames_username` (GeoNames username)
**Dev note (MaxMind DBs)**
- In development, ensure the MaxMind DBs are downloaded:
DISCOURSE_MAXMIND_ACCOUNT_ID=... DISCOURSE_MAXMIND_LICENSE_KEY=... bundle exec rake maxminddb:get
Restart web/sidekiq afterward so `DiscourseIpInfo` reloads the DBs.
---
## Settings
| Setting | Default | Description |
|---|---:|---|
| `location_ip_granularity` | `city` | Controls stored level: `country`, `province` (admin1), or `city`. |
| `location_geonames_username` | `""` | GeoNames username for `getJSON` requests. Acts as a feature flag
(blank => skip). |
| `location_ip_lookup_cooldown_days` | `1` | Per‑user cooldown between IP lookups (0 disables cooldown). |
| `locations_skip_ip_based_location_update_if_existing` | `true` | Skip IP lookup when existing
`geo_location` already has **lat + lon**. |
| `location_ip_auto_lookup_enabled` | `false` | Auto‑enqueue IP lookups on post creation. Rake task still
works when off. |
---
## Flow
- `post_created` → enqueue `Jobs::Locations::IpLocationLookup` with user ID + IP.
- Job:
- Guards: plugin enabled, users map enabled, GeoNames username present, MaxMind env vars present, cooldown
OK, and optional “existing location” check.
- Uses `DiscourseIpInfo.get(ip)` to get `geoname_ids`.
- Resolves GeoNames IDs, picks feature by granularity, builds `geo_location`.
- Saves `geo_location` to user custom field + updates `locations_user` table.
---
## Job + Hook
**Hook**
- `post_created` now enqueues `Jobs::Locations::IpLocationLookup`
- In development, IP is overridden to a fixed test IP (`2.139.231.7`) to ensure resolvable data.
**Job**
- `Jobs::Locations::IpLocationLookup` (new, in `app/jobs/regular/locations/ip_location_lookup.rb`)
- Logs key steps, skips when prerequisites are missing.
- Writes `geo_location` only when successfully built.
---
## GeoNames Helpers
New modules in `lib/locations/`:
- `GeoNamesClient`
- Calls `https://secure.geonames.org/getJSON` via `FinalDestination::HTTP`.
- Normalizes `geoname_id`, `fcl`, `fcode`, `lat`, `lon`, etc.
- Caches only successful lookups (avoids caching nil).
- `GeoNamesGranularityPicker`
- Selects best `PCLI` / `ADM1` / `PPL*` by desired granularity.
- `GeoLocationBuilder`
- Builds `geo_location` hash with correct `lat/lon`, `state`/`city` based on granularity.
---
## Rake Task
New rake task in `lib/tasks/locations.rake`:
**Task**
rake locations:enqueue_user_ip_location_lookups[username_pattern,pattern_type,delay]
**Behavior**
- Iterates users and enqueues the IP lookup job using `user.ip_address`.
- Progress is based on **matched population** (not total users).
- Skips enqueue when IP is blank.
**Options**
- `username_pattern` (optional): filter users by username.
- `pattern_type`: `string` (default substring match) or `regex`.
- `delay`: seconds between enqueues (float, default `0`).
**Help**
rake locations:enqueue_user_ip_location_lookups:help
This is not a simple lookup, we do more than that - this will allow you to set a specific granularity (e.g. city) for all automatically determined locations in order to protect user privacy whilst increasing community trust.
(Yes, there will be some issues with VPNs and I’m afraid we can’t easily overcome that).
Once I’m satisfied this is working sufficiently well I will merge it.
It sits behind a feature flag in any case.
I’ll keep you posted, but exciting times, this is potentially one of the best additions to Locations we may have had for a while.
Thanks again to @祁同伟 and @nathank !!
And yes, there will also be a rake task to do this for all existing users …
12 Likes
Canapin
(Coin-coin le Canapin)
January 31, 2026, 6:59pm
1212
Is it possible to show notices on Discourse’s backend through a plugin, for cases like this?
I could easily have missed your post
1 Like