Home › Forums › ACF PRO › update_field with nested groups and repater fields. › Reply To: update_field with nested groups and repater fields.
well I tried all the possibilities without luck…
So to fix this I used the update_post_meta function.
$addresses = get_field( 'company', $post_id );
$counter = 0;
foreach ( $addresses as $key => $address) {
foreach ($address as $k => $adr) {
$field = 'company_addresses_' . $counter . '_address_';
$counter++;
if( $adr['address']['geocode'] ){
$gaddress = $adr['address']['geocode']['address'];
if( $geocode = $this->getGeoData( $gaddress ) ){
$fields = [
'formatted_address' => $geocode['formatted_address'],
'country' => $geocode['country'],
'country_code' => $geocode['country_code'],
];
$company = get_field('company');
foreach ($fields as $key => $value) {
update_post_meta( $post_id , $field . $key, $value );
}
}
}
}
}
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.