Support

Account

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);