I have a site that requires to search for lat long information before been saved / updated a member profile, this is searched from google on reverse geolocation through a custom file name location.

I am not looking the function on solve that, I ma looking way on hook the function

Any suggest on how to solve that?

  • 2
    Hm, are you sure you want to do this before update? Why exactly? It is usually easy in WP inserts to hook right after it happened, but right before is challenging.
    – Rarst
    Jan 6, 2014 at 22:22
  • Cause I need user enter some location info and then make a map for all users, then I will need a latlong key pair for display positions on a map
    – Carlos
    Jan 7, 2014 at 0:17
  • I am sorry, that doesn't quite explain to me why before rather than after matters. Maybe you could provide your data flow for this step by step?
    – Rarst
    Jan 7, 2014 at 0:53

1 Answer 1


you can use something like this

 *  Get City state from zipcode
function rtp_get_city_state($location) {

    $details_url = 'http://maps.google.com/maps/api/geocode/json?address='.$location.'&sensor=false';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $details_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $response = json_decode(curl_exec($ch), true);

    if ($response['status'] != 'OK') {
        return null;

  • Sure, I though, my question is no clear, the question is how to hook it before update / save memeber. I have not found that
    – Carlos
    Jan 6, 2014 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.