gform_entries_field_header_pre_export

gform_entries_field_header_pre_export

DescriptionUsageParametersExamples1. Replace a Specific Label2. Replace Multiple Labels3. Remove charactersPlacementSource CodeSince

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.

gform_editor_js

gform_editor_js

DescriptionUsageExamples1. Basic example2. Adding a custom setting to all field types3. Set default date formatSource Code

Description
This action hook can be used to inject Javascript into the form editor page.
Usage
add_action( 'gform_editor_js', 'editor_script' );

Examples
1. Basic example
add_action( 'gform_editor_js', 'editor_script' );
function editor_script(){
echo '';
}

2. Adding a custom setting to all field types
This example adds a custom setting, which has been implemented using gform_field_standard_settings, gform_field_appearance_settings, or gform_field_advanced_settings, to the fields.
add_action( 'gform_editor_js', function () {
echo '' . PHP_EOL;
} );

3. Set default date format
This example sets the default date format for date type fields to dmy_dot.
add_action( 'gform_editor_js', function () {
echo '' . PHP_EOL;
} );

Source Code
This filter is located in js.php.

gform_enable_password_field

gform_enable_password_field

DescriptionUsageParametersExamplesSource Code

Description
Use this filter to enable the password field. Useful when developing add-ons that require a password field.
Usage
add_filter( 'gform_enable_password_field', '__return_true' );

Parameters

$is_enabled bool
Value to be filtered. True enables the password field; false disables it.

Examples
This example enables the password field.
add_filter( 'gform_enable_password_field', '__return_true' );

Source Code
This action hook is located in form_detail.php.

gform_entry_detail_content_before

gform_entry_detail_content_before

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this action hook to add extra text/sections before the main content on the Entry detail page.
Usage
1add_action( 'gform_entry_detail_content_before', 'add_main_text_before', 10, 2 );

Parameters

$form Form Object
The form from which the entry value was submitted.

$entry Entry Object
The current entry.

Examples
This example adds a new section with a header and text.
1234add_action( 'gform_entry_detail_content_before', 'add_main_text_before', 10, 2 );function add_main_text_before( $form, $entry ) {    echo '

Main Content Before
some stuff

';}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFEntryDetail::lead_detail_page() in entry_detail.php.

gform_email

gform_email

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the email field and can be used to modify the 「Email」 label.
Usage
Applies to all forms.
add_filter( 'gform_email', 'change_email', 10, 2 );

Applies to a specific form. In this case, form id 5.
add_filter( 'gform_email_5', 'change_email', 10, 2 );

Parameters

$label string
The label to be filtered.

$form_id integer
The current form』s id.

Examples
This example changes the default email label:
add_filter( 'gform_email', 'change_email', 10, 2 );
function change_email( $label, $form_id ) {
return 'Your Email';
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GF_Field_Email::get_field_input() in includes/fields/class-gf-field-email.php.

gform_entries_field_value

gform_entries_field_value

DescriptionUsageParametersExamples1. Display category names2. Display choice label3. File Upload Field4. Link to user profilePlacementAdditional NotesSource Code

Description
Use this filter to change the field』s value before getting displayed on the Entry list page. Useful when creating custom field types that require special formatting for the entry list.
Usage
add_filter( 'gform_entries_field_value', 'modify_entry_values' );

Parameters

$value string
The current entry value to be filtered.

$form_id integer
The ID of the form from which the entry value was submitted.

$field_id integer
The ID of the field from which the entry value was submitted.

$entry Entry Object
The current entry.

Examples
1. Display category names
This example assumes the original value is a comma delimited list of category IDs (i.e. 『1,3,4』). We then break the IDs into an array, loop through each ID to get the category name, and format the category name into an unordered list.
add_filter( 'gform_entries_field_value', 'display_category_names', 10, 3 );
function display_category_names( $value, $form_id, $field_id ) {

if ( $form_id != 3 || $field_id != 4 ) {
return $value;
}

$newvalue = *;
$categories = explode( ',', $value );

foreach($categories as $category) {
$new_value .= '

  • ' . get_cat_name( $category ) . '
  • ';
    }

    return '

      ' . $new_value . '

    ';
    }

    2. Display choice label
    This example displays the choice label instead of value for choice based fields.
    add_filter( 'gform_entries_field_value', function ( $value, $form_id, $field_id, $entry ) {
    $field = GFAPI::get_field( $form_id, $field_id );
    $value_fields = array(
    'checkbox',
    'radio',
    'select'
    );

    if ( is_numeric( $field_id ) && in_array( $field->get_input_type(), $value_fields ) ) {
    $value = $field->get_value_entry_detail( RGFormsModel::get_lead_field_value( $entry, $field ), '', true, 'text' );
    }

    return $value;

    }, 10, 4 );

    3. File Upload Field
    This example shows how you can define the markup returned for the file upload type field.
    add_filter( 'gform_entries_field_value', 'file_upload_field_values', 10, 4 );
    function file_upload_field_values( $value, $form_id, $field_id, $entry ) {
    $field = GFAPI::get_field( $form_id, $field_id );

    if ( is_object( $field ) && $field->get_input_type() == 'fileupload' ) {
    $file_path = rgar( $entry, $field_id );

    if ( $field->multipleFiles ) {
    $uploaded_files_arr = empty( $file_path ) ? array() : json_decode( $file_path, true );
    $file_count = count( $uploaded_files_arr );
    if ( $file_count > 1 ) {
    $value = empty( $uploaded_files_arr ) ? '' : sprintf( esc_html__( '%d files', 'gravityforms' ), count( $uploaded_files_arr ) );

    return $value;
    } elseif ( $file_count == 1 ) {
    $file_path = current( $uploaded_files_arr );
    } elseif ( $file_count == 0 ) {
    return '';
    }
    }

    if ( ! empty( $file_path ) ) {
    $thumb = GFEntryList::get_icon_url( $file_path );
    $file_path = esc_attr( $file_path );
    $value = "";
    }

    }

    return $value;
    }

    4. Link to user profile
    This example shows how you can link the value of the entry created_by property to the user profile page.
    add_filter( 'gform_entries_field_value', function ( $value, $form_id, $field_id, $entry ) {
    if ( $field_id === 'created_by' && ! empty( $value ) ) {
    $value = sprintf( '%s', esc_url( get_edit_user_link( $entry['created_by'] ) ), esc_html( $value ) );
    }

    return $value;

    }, 10, 4 );

    Placement
    This code should be placed in the functions.php file of your active theme.
    Additional Notes
    This hook is useful for storing entry values in one format, while displaying them on the entries page in another (refer to the example above).
    Source Code
    This filter is located in the following methods:

    GFEntryList::leads_page() in entry_list.php
    GFResults::get_default_field_results() in includes/addon/class-gf-results.php

    gform_editor_sidebar_panel_content

    gform_editor_sidebar_panel_content

    DescriptionUsageParametersExamples1. Add a new panelPlacementSinceSource Code

    Description
    The gform_editor_sidebar_panel_content action hook is used to echo the content for a custom panel in the form editor sidebar. Use the gform_editor_sidebar_panels filter to register the panel.
    Usage
    The base action which would run for all forms and all custom tabs would be used like so:
    add_action( 'gform_editor_sidebar_panel_content', 'your_function_name', 10, 2 );

    You can target a specific tab by adding the tab id after the hook name.
    add_action( 'gform_editor_sidebar_panel_content_thepanelid', 'your_function_name', 10, 2 );

    You can target a specific tab and form by adding the id』s after the hook name.
    add_action( 'gform_editor_sidebar_panel_content_thepanelid_6', 'your_function_name', 10, 2 );

    Parameters

    $panel array
    The properties of the panel being displayed.

    $form Form Object
    The form currently being edited.

    Examples
    1. Add a new panel
    add_action( 'gform_editor_sidebar_panel_content_my_custom_panel_1', function ( $panel, $form ) {
    echo 'the content of my custom panel.';
    }, 10, 2 );

    Placement
    This code should be placed in the functions.php file of your active theme or a custom functions plugin.
    Since
    This action hook was added in Gravity Forms v2.5.
    Source Code
    This action hook is located in GFFormDetail::forms_page() in form_detail.php

    gform_enable_shortcode_notification_message

    gform_enable_shortcode_notification_message

    DescriptionUsageParametersSource CodeSince

    Description
    Allows the disabling of the notification message defined in the shortcode.
    Usage
    1add_filter( 'gform_enable_shortcode_notification_message', 'your_function_name', 10, 2 );

    Parameters

    true bool
    If the notification message shortcode should be used.

    $form array
    The Form Object.

    $lead array
    The Entry Object.

    Source Code
    This filter is located in common.php.
    Since
    This filter was added in Gravity Forms 1.9.2.

    gform_dropdown_no_results_text

    gform_dropdown_no_results_text

    DescriptionUsageParametersExamplesPlacementSource Code

    Description
    Use this filter to change the default 「No Results」 placeholder text on Drop Down fields when using the enhanced user interface.
    Usage
    add_filter( 'gform_dropdown_no_results_text', 'set_no_results_text', 10, 2 );

    You can also target a specific form by adding the form id after the hook name.
    add_filter( 'gform_dropdown_no_results_text_6', 'set_no_results_text', 10, 2 );

    Parameters

    $text string
    The text to be filtered.

    $form_id integer
    ID of current form.

    Examples
    This example changes the no results text to 「No results found」.
    add_filter( 'gform_dropdown_no_results_text_185', 'set_no_results_text', 10, 2 );
    function set_no_results_text( $text, $form_id ) {
    return 'No results found';
    }

    Placement
    This code should be placed in the functions.php file of your active theme.
    Source Code
    This filter is located in GFFormDisplay::get_chosen_init_script() in form_display.php.

    gform_entry_detail_grid_display_empty_fields

    gform_entry_detail_grid_display_empty_fields

    DescriptionUsageParametersExample1. Force display2. Use the cookie set by the 「show empty fields」 checkboxPlacementSource CodeSince

    Description
    Allow displaying empty fields on the entry detail page/print view even if option is not checked.
    Usage
    add_filter( 'gform_entry_detail_grid_display_empty_fields', 'your_function_name' );

    Parameters

    $display_empty_fields bool
    Whether empty fields should be displayed.

    $form Form Object
    The form object the entry currently being viewed belongs to.

    $entry Entry Object
    The entry currently being viewed.

    Example
    1. Force display
    add_filter( 'gform_entry_detail_grid_display_empty_fields', '__return_true' );

    2. Use the cookie set by the 「show empty fields」 checkbox
    This example can be used to include empty fields in the entry printout.
    add_filter( 'gform_entry_detail_grid_display_empty_fields', function ( $display_empty_fields ) {
    if ( ! $display_empty_fields ) {
    $display_empty_fields = rgget( 'gf_display_empty_fields', $_COOKIE );
    }

    return $display_empty_fields;
    } );

    Placement
    This code should be placed in the functions.php file of your active theme.
    Source Code
    $display_empty_fields = apply_filters( 'gform_entry_detail_grid_display_empty_fields', $display_empty_fields, $form, $lead );

    This filter is located in GFEntryDetail::lead_detail_grid() in entry_detail.php.
    Since
    This filter was added in version 1.8.18.