Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Only for jet-engine repeater field
* In this example, i want to update repeater meta_field name = company-services
* 3 columns in repeater field _service-image, _service-name, _service-description
*/
//Example value from my fluent form
$value_from_form = array(
array("Service 1","Description 1"),
array("Service 2","Description 2"),
);
$repeater_values = jet_engine_repeater_services_populate($value_from_form);
update_post_meta( $post_id , 'company-services', $repeater_values );
// Populate the value into serialize array
function jet_engine_repeater_services_populate( $repeater_array ) {
$serialize_array = array();
foreach($repeater_array as $key=>$row) {
$service_name = $row[0];
$service_desc = $row[1];
if ($service_name != '' || $service_desc != '') {
$serialize_array['item-'.$key] = array(
'_service-image' => '', //must indicate even no value
'service-name' => $service_name ,
'_service-description' => $service_desc,
);
}
}
return $serialize_array;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment