Hello,
I’m trying to copy the data in repeater fields while saving. It works when priority is low (1), but that gives the old values. When priority is high (20), it doesn’t get past if (have_rows()) (which returns “”). It does work correctly when called from elsewhere (i.e., not during acf/save_post).
Any idea why or how to fix? Thank you very much for any help!
function motw_acf_save_post() {
$screen = get_current_screen() ;
if ( strpos( $screen->id, "acf-options-motw" ) == true ) {
$list = get_option( 'motw_list' ) ;
if ( have_rows( 'motw_repeater', 'options' ) ) {
while ( have_rows( 'motw_repeater', 'options' ) ) {
the_row();
$list[ get_sub_field( 'motw_date' ) ] = get_sub_field( 'motw_name' )[ 0 ]->post_title ;
}
ksort( $list, SORT_NUMERIC ) ;
update_option( 'motw_list', $list, false ) ;
}
}
}
add_action( 'acf/save_post', 'motw_acf_save_post', 20 ) ;