Using Gravity Forms ‘gform_leads_before_export’ PHP filter

The gform_leads_before_export filter allows you to modify Gravity Forms entries before they are exported.

Usage

To apply this filter to all forms, use:

add_filter('gform_leads_before_export', 'my_modify_entries_before_export_function', 10, 3);

To apply this filter to a specific form, use:

add_filter('gform_leads_before_export_{$form_id}', 'my_modify_entries_before_export_function', 10, 3);

Parameters

  • $entries (array) – An array of entry objects to be exported.
  • $form (array) – The current form object.
  • $paging (array) – The current paging for the export. It includes the following properties:
    • offset (integer) – Increases by 1 with each “page” of entries the export has processed.
    • page_size (integer) – Number of entries per page. Defaults to 20.

More information

See Gravity Forms Docs: gform_leads_before_export

Examples

Replace user ID with user display name

This example demonstrates how to use the gform_leads_before_export filter to convert the entry object’s default “created_by” property (which is a user ID) to the user’s display name.

add_filter('gform_leads_before_export', 'use_user_display_name_for_export', 10, 3);

function use_user_display_name_for_export($entries, $form, $paging) {
    foreach ($entries as &$entry) {
        $user = new WP_User($entry['created_by']);
        if (!$user->ID)
            continue;

        $entry['created_by'] = $user->get('display_name');
    }
    return $entries;
}

Place this code in the functions.php file of the active theme, a custom functions plugin, or a custom add-on.