Skip to content

Instantly share code, notes, and snippets.

@jennlee20
Last active October 7, 2020 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jennlee20/e56432004ea962a56b90bc9ae245eb07 to your computer and use it in GitHub Desktop.
Save jennlee20/e56432004ea962a56b90bc9ae245eb07 to your computer and use it in GitHub Desktop.
<?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