I’m currently trying to update a sub field value inside a nested repeater and group field. I can’t really seem to figure out why this code is not working yet. Hopefully someone can give a clear explanation, this is my current code:
add_action('acf/save_post', 'custom_codeveld_acf_save_post', 20);
function custom_codeveld_acf_save_post( $post_id ) {
$the_post = get_post($post_id);
if( $the_post->post_type == 'post' ) {
//Repeater field
if( have_rows('codevelden', $post_id) ):
while( have_rows('codevelden', $post_id) ) : the_row();
//Group field
if( have_rows('codegroep', $post_id) ):
while( have_rows('codegroep', $post_id) ) : the_row();
update_sub_field('codeveld', "Test");
endwhile;
endif;
endwhile;
endif;
}
}
I see the nested repeater but I do not see the group field.