Scheduled Entry Export for Gravity Forms Hooks, Actions and Filters
These hooks allow third-party developers to deeply customize the export process, from modifying how data is queried to changing how the final file is formatted and delivered.
Filters
Filters allow you to modify data before it is processed or saved by the plugin.
gform_scheduled_exports_search_criteria
Allows you to modify the search criteria used to query Gravity Forms entries before they are fetched from the database.
Parameters:
$search_criteria(array): The Gravity Forms search criteria array.$form_id(int): The ID of the form.$feed_id(int): The ID of the active feed.$meta(array): The feed settings metadata.
Example: Only export entries marked as “read”.
add_filter( 'gform_scheduled_exports_search_criteria', function( $search_criteria, $form_id, $feed_id, $meta ) {
$search_criteria['field_filters'][] = array(
'key' => 'is_read',
'value' => true,
);
return $search_criteria;
}, 10, 4 );
gform_scheduled_exports_entries
Allows you to modify the final array of entries right before the CSV is generated. This is useful if you need to run complex logic on the dataset that the standard Gravity Forms search criteria cannot handle.
Parameters:
$filtered_entries(array): The array of entries after conditional logic is applied.$form(array): The Gravity Forms form object.$feed(array): The feed object.$meta(array): The feed settings metadata.
Example: Remove the very first entry from the export.
add_filter( 'gform_scheduled_exports_entries', function( $filtered_entries, $form, $feed, $meta ) {
array_shift( $filtered_entries );
return $filtered_entries;
}, 10, 4 );
gform_scheduled_exports_csv_separator
Allows you to change the delimiter (separator) used in the export file. By default, this is a comma (,).
Parameters:
$separator(string): The current separator (default is,).$form(array): The Gravity Forms form object.
Example: Change the delimiter to a tab character (useful for .TSV files).
add_filter( 'gform_scheduled_exports_csv_separator', function( $separator, $form ) {
return "\t";
}, 10, 2 );
gform_scheduled_exports_csv_headers
Allows you to add, remove, or rename columns in the exported CSV.
Parameters:
$headers(array): The array of CSV headers where the Key is the field ID and the Value is the column label.$form(array): The Gravity Forms form object.
Example: Add a custom column header to the CSV.
add_filter( 'gform_scheduled_exports_csv_headers', function( $headers, $form ) {
$headers['custom_column'] = 'My Custom Data';
return $headers;
}, 10, 2 );
gform_scheduled_exports_csv_row
Allows you to alter the data values inside a specific row of the CSV before it is written to the file. This pairs perfectly with the headers filter above.
Parameters:
$row(array): The formatted row data.$entry(array): The raw Gravity Forms entry object.$form(array): The Gravity Forms form object.$headers(array): The array of CSV headers.
Example: Add custom data to match the custom header added in the previous example.
add_filter( 'gform_scheduled_exports_csv_row', function( $row, $entry, $form, $headers ) {
$row[] = 'Custom Value for Entry ID ' . $entry['id'];
return $row;
}, 10, 4 );
gform_scheduled_exports_filepath
Allows you to change the temporary storage location and filename of the generated CSV.
Parameters:
$filepath(string): The absolute server path where the CSV will be saved.$form_id(int): The ID of the form.$feed_id(int): The ID of the active feed.$meta(array): The feed settings metadata.
Example: Force the file to save in a specific custom directory.
add_filter( 'gform_scheduled_exports_filepath', function( $filepath, $form_id, $feed_id, $meta ) {
return WP_CONTENT_DIR . '/my-custom-exports/export-' . $feed_id . '.csv';
}, 10, 4 );
gform_scheduled_exports_email_args
Allows you to modify all email arguments (To, Subject, Message, Headers, Attachments) right before the email is sent out.
Parameters:
$email_args(array): An array containingto,subject,message,headers, andattachmentskeys.$meta(array): The feed settings metadata.$form(array): The Gravity Forms form object.$filepath(string): The local path to the generated CSV file.
Example: Force CC an admin on every scheduled export email.
add_filter( 'gform_scheduled_exports_email_args', function( $email_args, $meta, $form, $filepath ) {
$email_args['headers'][] = 'Cc: [email protected]';
return $email_args;
}, 10, 4 );
Actions
Actions allow you to trigger custom functions and workflows at specific points during the plugin’s execution lifecycle.
gform_scheduled_exports_post_export
Fires at the very end of the background export process. This is extremely useful if you want to upload the generated file to a third-party server (like an AWS S3 bucket, a Dropbox folder, or an FTP server) instead of, or in addition to, emailing it.
Parameters:
$feed_id(int): The ID of the active feed.$form_id(int): The ID of the form.$filepath(string): The absolute server path to the generated CSV file.$fileurl(string): The publicly accessible URL to the CSV file.$meta(array): The feed settings metadata.
Example: Upload the file located at $filepath to a remote FTP server.
add_action( 'gform_scheduled_exports_post_export', function( $feed_id, $form_id, $filepath, $fileurl, $meta ) {
// Custom logic to handle the file upload
// my_custom_ftp_upload_function( $filepath );
}, 10, 5 );