<?php | |
add_action( 'gform_after_create_post_1', 'lc_gp_media_connect_to_acf_field', 10, 3 ); | |
/** | |
* Attach the uploaded images to the created post. | |
* | |
* @param int $post_id The Post ID for the post created with the form. | |
* @param array $lead The Lead Object. | |
* @param array $form The Form Object for the form used to create the post. | |
*/ | |
function lc_gp_media_connect_to_acf_field( $post_id, $lead, $form ) { | |
// Is the gp_media_library perk activated? | |
if ( ! function_exists( 'gp_media_library' ) ) | |
return; | |
$file_ids = gp_media_library()->get_file_ids( rgar( $lead, 'id' ), 2 ); | |
update_post_meta( $post_id, 'gallery', $file_ids ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment