Skip to content

Instantly share code, notes, and snippets.

@kristarella
Created April 29, 2015 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kristarella/dfd2b3be6a0f3bec94c1 to your computer and use it in GitHub Desktop.
Save kristarella/dfd2b3be6a0f3bec94c1 to your computer and use it in GitHub Desktop.
Convert Gravity Form multiselects to ACF format
<?php
add_action('gform_after_submission_14', 'reformat_multiselect', 10, 2);
function reformat_multiselect($entry, $form) {
$post_id = $entry['post_id'];
$selects = array(
'custom_field1' => 'ACF_field_key',
'custom_field2' => 'ACF_field_key',
'custom_field3' => 'ACF_field_key'
);
foreach ($selects as $name => $key) {
$custom = get_post_meta( $post_id, $name, false );
delete_post_meta( $post_id, $name );
$value = maybe_serialize($custom);
if (function_exists('update_field'))
update_field($key,$value,$post_id);
else
add_post_meta($post_id,$key,$value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment