gform_post_export_entries

Description

The gform_post_export_entries action is triggered after exporting entries from a form, allowing further actions to be performed.

Usage

add_action( 'gform_post_export_entries', 'my_function', 10, 5 );

Parameters

ParameterTypeDescription
$formarrayThe form object to get the entries from.
$start_datestringThe start date from where the entries exported will begin.
$end_datestringThe end date on which the entry export will stop.
$arrayarrayThe field IDs from which entries are being exported.
$export_idstringThe unique ID for the export. Since version 2.4.6.

Examples

Basic usage.

function my_function() {
	//Do something here
}
add_action( 'gform_post_export_entries', 'my_function', 10, 5 );

Append additional entries.

The following shows how additional entries can be appended to the entry export when using Gravity Forms 2.4.6 or greater.

add_action( 'gform_post_export_entries', function ( $form, $start_date, $end_date, $fields, $export_id ) {
	$entries = array(); // Define or get the additional entries here.

	$lines   = '';

	foreach ( $entries as $entry ) {
		$lines .= GFExport::get_entry_export_line( $entry, $form, $fields, array(), ',' );
		$lines .= "\n";
	}

	if ( ! seems_utf8( $lines ) ) {
		$lines = utf8_encode( $lines );
	}

	GFExport::write_file( $lines, $export_id );
}, 10, 5 );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

This action hook is located in export.php.

Since

This action was added in Gravity Forms version 1.9.3.

Added the “export_id” parameter in version 2.4.6.