Support

Account

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  );