Forum: Xprofile Fields

This forum is closed for new topics. However, you can still search for a solution in the old topics. For technical support related to the Xprofile Fields premium extension please open a new premium support ticket.

[Resolved]Geolocate existing users

Home Forums Xprofile Fields Geolocate existing users

This topic contains 9 replies, has 5 voices, and was last updated by  davidryal 3 years, 1 month ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #51025

    Morgan Schwartz
    Participant

    Hi

    We have a site with about 10,000 existing Buddypress users. Is their a way to batch geolocate them and get them into your custom table? Manually editing every user is not realistic.

    It would be great if you could provide a script or tool to do this.

    thanks!

    #51050

    Morgan Schwartz
    Participant

    anyone there?

    #51068

    Eyal Fitoussi
    Keymaster

    Hi Morgan,
    Sorry for missing out your post.

    Unfortunately, I don’t have such solution at the moment. However, with some PHP and MYSQL knolaged it should be possible to create it.

    Basically, you need a script that will pull all the members that have an address from database. Loop through those members, geocoded the address and save it in Geo my WP database table.

    GEO my WP already comes with a function that will geocode an address and save it in database. The function is:

    And can be found in geo-my-wp/includes/geo-my-wp-user-update-location.php

    So basically, with your script looping through all members, you can use this function in the loop by passing the user ID and the address. The function will geocode the address and save the data in Geo my WP table.

    The main reason I don’t have this script already made is the limitation of Google Maps API. Google API is limited to 2500 queries ( of geocoding ) per 24 hours per IP address. And abusing this limit might results in Google blocking your IP address from using its maps services. There is no way to track the usage per 24 and so you cannot know how many addressed you already geocoded when running the script. Also, on shared hosting, an IP address is also being shared between multiple sites. So if other sites on the same IP address are using Google API then it “eats up” your queries per 24 hours as well.

    So, having such a script where some users might not follow the query limit directions can be harmful for their site, and most likely I would be the one to blame if their site is being blocked by Google.

    The script I mentioned above should not be very difficult to write ( again, with some PHP and MYSQL knowledge ). But very important to remember, if you do write the script, is to place a delay of 2 to 3 seconds between each address being geocoded. Also remember to limit the number of address being geocoded per 24 hours. I would run no more then 1000 address per day just to be on the safe side.

    I hope that information helps.

    Let me know if you have any other questions.

    #51100

    Morgan Schwartz
    Participant

    thank you for this thorough reply .. very helpful!

    ok, i think i’ll write a script as you described and try to chug through our 10k users over the next week!

    i’m thinking one addition to your concept above might be to try and cache previously geocoded addresses to minimize hits to google’s API

    anyhow thanks for the guidance

    #51101

    Morgan Schwartz
    Participant

    would using the client side geocoder setting in your plugin help with the api limits?

    #51118

    Eyal Fitoussi
    Keymaster

    You are welcome Morgan,

    i’m thinking one addition to your concept above might be to try and cache previously geocoded addresses to minimize hits to google’s API

    GEO my WP geocoder already cache geocoded information in transient for, I think, 3 months.

    would using the client side geocoder setting in your plugin help with the api limits?

    Not with the custom code. At the moment, the client-side geocoder applies only to the address submitted in GEO my WP search forms. To use a client side geocoder required the script above to be AJAX powered loop and to use JavaScript to geocode the address. Such geocoder is on my add-ons todo list.

    Private Content Hidden
    #51463

    Eyal Fitoussi
    Keymaster

    This topic marked “Resolved” due to inactivity. If you wish to reply to this topic please change its status to “Not resolved”  before replying.

    #54059

    Miriam
    Participant

    Hey @Morgan,

    did you have success with your script? I’ve got the same problem and would like to geolocate my existing BP-users. Unfortunately I’m not a coder, so i’m not able to code the script. Would it be possible, that you send me your script? Of course I would donate you some money for that.

    Thanks a lot and greetings from Berlin
    Miriam

    #54571

    dlx
    Participant

    Hi! A solution for this would be great – I have the same problem…

    Best regards,
    Jan

    #54940

    davidryal
    Participant

    +1 here, 1500 users needing import. I’d totally pay for an import locations add-on that respects Google API daily limits..

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.