gform_entries_field_header_pre_export

Description

This filter can be used to override the field header in the entries export.

Usage

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

You can also 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 );

You can also 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.

Examples

1. 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 );

2. 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;
}

3. 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 );

Placement

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

Source Code

$label = gf_apply_filters( array( 'gform_entries_field_header_pre_export', $form_id, $field_id ), GFCommon::get_label( $field, $field_id ), $form, $field );

This filter is located in GFExport::start_export() in export.php.

Since

This filter was added in Gravity Forms 1.9.10.11.