Home › Forums › ACF PRO › Saving Google Map lat/lon data as post_meta › Reply To: Saving Google Map lat/lon data as post_meta
The problem with your first example was that you were not returning $value. Since it’s a filter you need to return something, either the original value or an updated one.
function rhm_update_lng_and_lat( $value, $post_id, $field ) {
update_post_meta( $post_id, 'loc_lat', $value['lat'] );
update_post_meta( $post_id, 'loc_lng', $value['lng'] );
return $value;
}
add_action('acf/update_value/name=map_location', 'rhm_update_lng_and_lat', 10, 3 );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.