Hi Guys,
I am trying to update the selected value of a radio button when a CPT is saved, here is what I have tried so far:
I have added logging to the function so I know it is reading the values for LookupCR and LookupDone but it is not updating the value of LookupDone even after update_field.
Error is one of the default options on the radio button.
function my_acf_lookup_cr($post_id)
{
while(the_flexible_field(“architectural_design_-_rfc”)) :
if(get_row_layout() == “new_cr”):
$lookupCR = get_sub_field(‘auto_lookup_cr’);
$lookupDone = get_sub_field(‘auto_lookup_done’);
if ($lookupCR == ‘Yes’) :
update_field(‘field_5d53ab1e9327d’, ‘Error’, $post_id );
endif;
$lookupDone = get_sub_field(‘auto_lookup_done’);
endif;
endwhile;
}
add_action(‘acf/save_post’, ‘my_acf_lookup_cr’, 20);
I managed to figure this out, I needed to use update_sub_field instead of update_field.