Home › Forums › ACF PRO › Adding a repeater row to a user › Reply To: Adding a repeater row to a user
Hi James, I’ve taken your advice and I’m able to add to one repeater field on one user, but not another when the database isn’t initialized for that user.
( my code is below )
$field_key = 'matched_users'; //$user1 is user1's ID //$user2 is user2's ID echo 'adding field...<br>'; $post_id1 = 'user_' . $user2; $value1 = get_field($field_key, $post_id1); $value1 = array("user" => $user1); update_field($field_key,$value1,$post_id1); $post_id2 = 'user_' . $user1; $value2 = get_field($field_key, $post_id2); $value2 = array("user" => $user2); update_field($field_key,$value2,$post_id2); echo '<br>added';
How would i initialize the database? With a blank add_row/update_field?
Thank you for your help so far.
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!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.