Updating ACF field data with acf/save_post on first save

Question

I’m using Google Maps API to grab coordinate information with an address from a set of ACF address fields. This works really well, but only if you click the save/update button twice. On the initial post save, the coordinate lat/lng fields remain blank.

function get_google_data() {
  // Requesting things from Google and updated fields with things like
  $_POST['acf']['field_5f6384e72ff22'] = array( 'lat' => NN.NNNN, 'lng' => -NN.NNNN );
}
add_action('acf/save_post', 'get_google_data', 1);
0
Austin 4 months 0 Answers 15 views 0

Leave an answer