fg_entryautomation_export_file_path

Description

This filter allows you to modify the path where the export file will be written to on your site’s system.

There are three important things to keep in mind when using this filter:

  1. The returned file path must contain the filename (see the example at the bottom of this documentation for how to get this correctly).
  2. The directory you intend to write the file to must already exist, make sure you’ve created the custom directory before running any tasks that could be effected by this filter.
  3. If you move the file path anywhere outside of the gravity_forms directory within your WordPress install’s uploads directory, you will no longer be able to directly download export files from the WordPress admin due to limitations in Gravity Forms core when custom file locations are used.

Usage

Global usage:

add_filter( 'fg_entryautomation_export_file_path', 'your_function_name', 10, 3 );

Form ID specific usage:

add_filter( 'fg_entryautomation_export_file_path_1', 'your_function_name', 10, 3 );

Parameters

Examples

This example shows you how to change the file path to a custom location on your site’s system.

As noted above the location being written to must already exist and you must include the file name in the path.

The example here grabs the file name and makes sure any merge tags within it are replaced with their necessary values.

add_filter( 'fg_entryautomation_export_file_path', function( $file_path, $task, $form ) {

    $file_name = sanitize_file_name( $task->merge_tags->replace_tags( $task['exportFileName'], [], false, false, false, 'text' ) . '.' . $task['exportFileType'] );
    $file_path = '/app/public/mycustomdirectory/' . $file_name;

    return $file_path;

}, 10, 3 );