Home › Forums › Add-ons › Repeater Field › adding a row to a repeater › Reply To: adding a row to a repeater
Hi @bosoxbill
I’m afraid you have some syntax errors in your code. I believe you need to do it like this instead:
// You need to set the variable instead of the value here
function my_pre_save_post_x( $post_id ) {
$row = array(
'game_date' => 'June 20, 1975',
'away_team' => 'Boston',
'away_score' => 0,
'home_team' => 'Cleveland',
'home_score' => 0,
);
/* Please use the field key instead of the field name because you use it
* before the saving process occured (pre_save_post). Also, you need to
* add the post ID to the add_row() function
*/
$i = add_row('field_1234567890abc', $row, $post_id);
}
add_filter('acf/pre_save_post' , 'my_pre_save_post_x', 10, 1);
To see the error message instead of the white screen, please take a look at this page: https://codex.wordpress.org/Debugging_in_WordPress.
I hope this helps 🙂
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.