Using Gravity Forms ‘gform_entries_field_header_pre_export’ PHP action

The gform_entries_field_header_pre_export is a Gravity Forms PHP filter that allows you to override the field header in the entries export.

Usage

A generic example of how to use the function:

add_filter('gform_entries_field_header_pre_export', 'set_column_header', 10, 3);

Target a specific form by adding the form id after the hook name (format: gform_entries_field_header_pre_export_FORMID):

add_filter('gform_entries_field_header_pre_export_10', 'set_column_header', 10, 3);

Target a specific field by adding the form id and the field id after the hook name (format: gform_entries_field_header_pre_export_FORMID_FIELDID):

add_filter('gform_entries_field_header_pre_export_10_3', 'set_column_header', 10, 3);

Parameters

  • $header (string): The header being used for the current field. Defaults to the field label (input label for multi-input fields).
  • $form (Form Object): The current form.
  • $field (Field Object): The current field.

More information

See Gravity Forms Docs: gform_entries_field_header_pre_export

Examples

Replace a Specific Label

In this example, we are replacing the label for field 3 of form 10.

add_filter('gform_entries_field_header_pre_export_10_3', function($header, $form, $field) {
    return 'your new header';
}, 10, 3);

Replace Multiple Labels

In this example, we are replacing the labels for multiple fields of form 5. The $labels array uses the field’s current label as the key to the new label.

add_filter('gform_entries_field_header_pre_export_5', 'replace_export_coloumn_headers', 10, 3);

function replace_export_coloumn_headers($header, $form, $field) {
    $labels = array(
        'Email' => 'email1',
        'Phone' => 'phone1',
        'Address (Street Address)' => 'street1',
    );

    return isset($labels[$header]) ? $labels[$header] : $header;
}

Remove characters

The following example shows how you can remove characters from the column labels, in this case newlines, tabs, and carriage returns.

add_filter('gform_entries_field_header_pre_export', function($header, $form, $field) {
    return str_replace(array("\n", "\t", "\r"), '', $header);
}, 10, 3);

This code should be placed in the functions.php file of your active theme.