Last active
April 14, 2018 18:25
-
-
Save leepettijohn/be55a852460386d1b044feea77b69837 to your computer and use it in GitHub Desktop.
From Gravity Form List to ACF Repeater Field
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 | |
/* Going from Gravity Form list to ACF Repeater functionality */ | |
add_action( 'gform_after_submission_9', 'list_to_repeater', 1, 2 ); | |
function list_to_repeater( $entry, $form ) { | |
/* Set the field ids for the custom list fields */ | |
$list_key = 'field_585ae03ad9aab'; | |
/* get and unserialize the list */ | |
$list_ser = rgar($entry,'17'); | |
$list_unser = unserialize($list_ser); | |
/* Create the list arrays */ | |
foreach($list_unser as $single_item){ | |
$value[] = array( | |
/* 'full_name' and 'email' are the slugs you gave the ACF repeater fields */ | |
'full_name' => $single_item['Full Name'], | |
'email' => $single_item['Email'] | |
); | |
/* Update the list fields */ | |
update_field($list_key,$value,$orderid->ID); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment