[FORMINATOR] Zapier integration / full path for file

Is there a way to output the full file path?
I use Zapier integration to send the form data to an AirTable spreadsheet and only the file name comes through, not the full path.

Is there any way to get the full file path?

Thank you

  • Ash

    Hello Ryan

    Would you please try the following code?

    add_filter( 'forminator_addon_formatted_submitted_data', function( $formatted_post_data, $post_data, $files_data, $form_fields ) {
    	$uploads = wp_upload_dir();
    	$formatted_post_data['upload-1']['name'] = $uploads['path'] . '/' . $formatted_post_data['upload-1']['name'];
    
    	return $formatted_post_data;
    }, 99, 4 );

    You can use this code in your child theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Please let me know if that works for you. Have a nice day!

    Cheers,
    Ash

  • Ash

    Or if that doesn't work, please try this one:

    function server_files_to_url( $entry, $form_id, $field_data_array ) {
        /**
         * remove this to apply to all form
         */
        $form_id_to_attach = 278;
        if ( (int) $form_id_to_attach !== (int) $form_id ) {
            return false;
        }
    
        foreach ( $field_data_array as $field_data ) {
            if ( isset( $field_data['name'] ) && 'upload-1' === $field_data['name'] ) {
                forminator_maybe_log( $field_data );
                if ( isset( $field_data['value'] ) && isset( $field_data['value']['file'] ) ) {
                    $file_props = $field_data['value']['file'];
                    if ( isset( $file_props['file_url'] ) ) {
                        $_FILES['upload-1'] = $file_props['file_url'];
                    }
                }
            }
        }
    
    }
    add_action( 'forminator_custom_form_submit_before_set_fields', 'server_files_to_url', 10, 3 );

    Set the form ID here: $form_id_to_attach = 278;

    Cheers,
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.