Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
The location module does not provide any support for determining location from an IP address.
That would be the domain of your IP2CC module, but they also don't support it, as mentioned in the issue you posted there (#376155: How can show state of US?).
Sorry if this doesn't correspond here, I've tested Location and I filled my needs except automatically select the country based on ip address. I now Location can go down to region, state, coordinates, but some sites need only country of the visitor, ip2cc does a good job on it.
I now this may require a LOT of work, but in a future (1 or 2 years), is this doable?
The functionality itself shouldn't be that hard and could be done in location, ip2cc or a new module.
I have thought a little about this and I don't think it should go in the location module.
Location just provides the base location functionality, it doesn't do integration with other modules (aside from the parent type modules: drupal core, cck, views). So if we add integration with ip2cc then we open the door to having to integrate with heaps of other modules too. Plus the location module is already fairly large.
I would guess that the maintainers of ip2cc would have a similar view for their module.
Which leaves the new module route.
A new module could be pretty easily created to integrate the two modules using the functions ip2cc provides and hook_locationapi(), which is provided by location.
If I get some time soon and no one else has done it already I will put something simple together.
Comments
Comment #1
yesct commentedtagging.
Comment #2
rooby commentedThe location module does not provide any support for determining location from an IP address.
That would be the domain of your IP2CC module, but they also don't support it, as mentioned in the issue you posted there (#376155: How can show state of US?).
Comment #4
federico commentedSorry if this doesn't correspond here, I've tested Location and I filled my needs except automatically select the country based on ip address. I now Location can go down to region, state, coordinates, but some sites need only country of the visitor, ip2cc does a good job on it.
I now this may require a LOT of work, but in a future (1 or 2 years), is this doable?
Is this out of the scope of this module?
Thanks
Comment #5
rooby commentedThe functionality itself shouldn't be that hard and could be done in location, ip2cc or a new module.
I have thought a little about this and I don't think it should go in the location module.
Location just provides the base location functionality, it doesn't do integration with other modules (aside from the parent type modules: drupal core, cck, views). So if we add integration with ip2cc then we open the door to having to integrate with heaps of other modules too. Plus the location module is already fairly large.
I would guess that the maintainers of ip2cc would have a similar view for their module.
Which leaves the new module route.
A new module could be pretty easily created to integrate the two modules using the functions ip2cc provides and hook_locationapi(), which is provided by location.
If I get some time soon and no one else has done it already I will put something simple together.
Comment #6
alexbk66- commentedI added GeoIP to the title, the module detects the location to the city level, pretty good.
Would be nice to prepopulate the location fields based on ip, both for user and node locations, not only the country.
Comment #7
alexbk66- commentedDuplicate of #484414: Default user location given by Geouser, GeoIP
Comment #8
rooby commentedThis isn't a feature that will be added to this module.
See post #5 above for more information.