Julien_Bonnier asks how to execute backend code in Discourse to redirect users outside Quebec using the Maxmind API, noting that a self-hosted instance may be required. Falco explains that a plugin is needed, and Discourse already includes MaxMind integration via DiscourseIpInfo.get(ip), but that GeoIP accuracy is unreliable. Jagster warns about GeoIP unreliability, while pfaffman shares an example of limited precision and suggests alternative solutions. Julien confirms that partial accuracy is acceptable for a first filter. Heliosurge proposes a theme-component for language-specific redirection, and pfaffman suggests using a user custom field. merefield proposes enhancing the Locations plugin to auto-detect and lock location in user profiles. RGJ suggests modifying a geo-blocking plugin to allow only Quebec users. RGJ also notes that hosting with Communiteq on the Professional plan or higher allows plugin support for this use case.
But will I be able to use that plugin with the SaaS version of Discourse (with the pro plan)?
No need for API calls, as Discourse ships with MaxMind integration out of the box, and you can simply call DiscourseIpInfo.get(ip) from your plugin.
Is this precise enough to target user from Quebec, Canada only. Most GeoIP services I found had a country precision but were not able to target a specific province in Canada.
If you are on our hosting, please contact our support. We can help you with custom plugins in our Enterprise plan.
So not possible with the Standard plan? My guess is the Enterprise plan is at least 3x the price of the pro plan.
There will be a bunch of ways that this could have false positives or negatives. Your best bet is some other solution to the problem that you’re solving with the redirect.
Instead of a full redirect you might be able to use a theme-component that for example if your looking to redirect french users. It could maybe use Local to populate a popup in the login screen for the prefered site for francophones.
I’d welcome a PR to the Locations plugin (as a site setting) to determine a User’s location automatically and set this in their profile which in this mode could be read only (another setting) to prevent them changing it themselves (but might be by admin on request).
Then, as a bonus, you would be able to see everyone on a map
You could turn the logic in our geo blocking plugin around and instead of blocking certain regions, you could block all except certain regions. Shouldn’t be too hard - bonus points for the person that can do it with a one character edit. Hint: line 37 !
Or you can host with communiteq on the Professional plan or up. In that case we’ll even extend the plugin for your use case.