Add it
add_action( 'gform_after_submission_3', 'set_acf_file_uploads', 10, 2 );
function set_acf_file_uploads( $entry, $form ) {
$post_id = $entry['post_id'];
$file_fields = array(
'19' => 'file_1',
'20' => 'file_2',
'21' => 'file_3',
'22' => 'file_4',
'23' => 'file_5',
'24' => 'file_6',
);
foreach ( $file_fields as $gf_field_id => $acf_field_name ) {
$file_url = rgar( $entry, $gf_field_id );
if ( $file_url ) {
$attachment_id = attachment_url_to_postid( $file_url );
if ( $attachment_id ) {
update_field( $acf_field_name, $attachment_id, $post_id );
error_log("Updated ACF field $acf_field_name with attachment ID $attachment_id");
} else {
error_log("Failed to get attachment ID from URL: $file_url");
}
} else {
error_log("No file uploaded for GF field ID $gf_field_id");
}
}
Testing Response