Last active
October 7, 2020 05:56
-
-
Save jennlee20/e56432004ea962a56b90bc9ae245eb07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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