Home › Forums › Backend Issues (wp-admin) › Repeater from user profile form to post › Reply To: Repeater from user profile form to post
I figured it out. Here is the solution if someone is interested:
It was not so hard when I understood the process. I use a regular foreach to loop through the objects, and put the results in an array. Then I assign the array to the repeaterfield and the correct post. No need for super clunky $name_keys and separate update_sub_fields.
$repeater = 'field_61e1ea4738085'; // the field name of the repeater field
$repeaterObjects = $values['field_61e1ea4738085']; //getting the values from the $_POST['acf'] array
// loop through the rows
//size=f repeaterobject returns 2 which is fine
foreach($repeaterObjects as $obj) {
// building the field names of the repeater fields for the database
$breeder_data [] =
[
'breeder_owner_name' => $obj['field_61e1ea5c38086'],
'breeder_owner_address' => $obj['field_61e1ea6738087'],
'breeder_owner_postal_address' => $obj['field_61e1ea7a38088'],
'breeder_owner_email' => $obj['field_61e1ea8e38089'],
'breeder_owner_phone' => $obj['field_61e1eaa13808a'],
];
}
update_field( $repeater, $breeder_data, $id);
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!
🚀 ACF & ACF PRO 6.0.7 are now available.
— Advanced Custom Fields (@wp_acf) January 18, 2023
✨This release contains bug fixes and improvements while we continue to work on the next major release of ACF.https://t.co/wQgAOpwmUI
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.