Skip to content

Instantly share code, notes, and snippets.

@incognitozen
Last active April 19, 2020 07:20
Show Gist options
  • Save incognitozen/58a656c7dcb7e639cda0eec25f4c9a58 to your computer and use it in GitHub Desktop.
Save incognitozen/58a656c7dcb7e639cda0eec25f4c9a58 to your computer and use it in GitHub Desktop.
Gravity forms list field to ACF repeater field
Add the following in your functions.php file.
@incognitozen
Copy link
Author

// Change the number in the following line with the id of your form. --- >  gform_after_submission_3. For me the form had id 3
add_action( 'gform_after_submission_3', 'list_field_to_acf_accolades', 10, 2 );
function list_field_to_acf_accolades( $entry, $form ){
$id = $entry['post_id'];
// Change the number 2 in ( rgar( $entry, '2' ) );  with the id of the list field in your gravity form. For me this was number 2.
$acfFields = maybe_unserialize( rgar( $entry, '2' ) );
$val = array();
foreach ( (array)$acfFields as $key => $data) {
$description = array();
$description['pros'] = $data;
$val[] = $description;
}
update_field( 'pros', $val, $id ); 
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment