Home › Forums › Add-ons › Repeater Field › update_field only works if followed by exit; › Reply To: update_field only works if followed by exit;
No, the new row doesn’t show and there’s is no new entry in the wp_postmeta table for that post_id. I’ve even tried to simplify the code by using add_row and the effect is the same:
$row = array(
'date' => date('F j, Y g:i a'),
'action' => 'Status changed '.$old.' to '.$new
);
$new_row_count = add_row( 'history', $row, $post->ID );
The above fails to add the new row (and no new entry in the database) whereas:
$row = array(
'date' => date('F j, Y g:i a'),
'action' => 'Status changed '.$old.' to '.$new
);
$new_row_count = add_row( 'history', $row, $post->ID );
var_dump( $new_row_count );
exit;
does add the new entry as expected (and is added ok to the wp_postmeta table) and the $new_row_count is as expected.
I’ll continue to debug by stepping into the ACF core and adding die() points to see if I can pin down exactly where it’s going wrong.
*Update* I think this is all down to me trying to add a new repeater row when the post status changes and WordPress does that in an Ajax request. I think the simplest solution is just to maintain a separate ACF ‘Status’ field which will also have the benefit of allowing me more statuses 😉
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.