gform_entries_view

gform_entries_view

DescriptionUsageParametersExamplesSource Code

Description
Triggers when viewing an entry with a non-standard entry type.
Usage
add_action( 'gform_entries_view', 'my_function', 10, 3 );

Parameters

$view string
The current entry type.

$form_id string
The ID of the form that the entry belongs to.

$entry_id string
The ID of the current entry.

Examples
if ( rgget('view') == 'my_view' ) {
add_action( 'gform_entries_view', 'my_function', 10, 3 );
function my_function($view, $form_id, $entry_id) {
//Display the view for this entry type
}
}

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

gform_entries_first_column

gform_entries_first_column

DescriptionUsageParametersExamplesSource Code

Description
Use this action hook to add content to the entry list』s first column.
Usage
1add_action( 'gform_entries_first_column', 'first_column_content', 10, 5 );

Parameters

$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.

$value string
The entry value of the field id for the current lead.

$entry Entry Object
The current entry.

$query_string string
The current page』s query string in the format 「name1=val1&name2=val2」.

Examples
This is a very basic example that demonstrates how to add the content 「Sample Text」 to the entry list』s first column.
1234add_action( 'gform_entries_first_column', 'first_column_content', 10, 5 );function first_column_content( $form_id, $field_id, $value, $entry, $query_string ) {    echo 'Sample text.';}
Source Code
This filter is located in GFEntryList::leads_page() in entry_list.php.

gform_entries_first_column_actions

gform_entries_first_column_actions

DescriptionUsageParametersExamples1. Print Entry Action2. Mark As PaidSource Code

Description
Use this action hook to add extra action links to the entry row on the entry list page.
Usage
add_action( 'gform_entries_first_column_actions', 'first_column_actions', 10, 5 );

Parameters

$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.

$value string
The entry value of the field id for the current lead.

$entry Entry Object
The current entry.

$query_string string
The current page』s Query String in the format 「name1=val1&name2=val2」.

Examples
1. Print Entry Action
This example demonstrates how to add Gravity Form』s print entry functionality (currently available on the Entry Detail page) as an action link on the Entries list page.
add_action( 'gform_entries_first_column_actions', 'first_column_actions', 10, 4 );
function first_column_actions( $form_id, $field_id, $value, $entry ) {
$url = add_query_arg( array(
'gf_page' => 'print-entry',
'fid' => $form_id,
'lid' => $entry['id'],
'notes' => '1',
), site_url() );

printf( '| Print', $url );

}

2. Mark As Paid
add_action( 'gform_entries_first_column_actions', function ( $form_id, $field_id, $value, $entry ) {
echo "|

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_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_entries_column

    gform_entries_column

    DescriptionUsageParametersExamplesSource Code

    Description
    Use this action to inject markup to any non-first column of every entry in the entry list grid.
    Usage
    add_action( 'gform_entries_column', 'add_icon', 10, 5 );

    Parameters

    $form_id integer
    ID of the current form.

    $field_id integer
    ID of the field that this column applies to.

    $value string
    Current value that will be displayed in this cell.

    $entry Entry Object
    Current entry object.

    $query_string string
    Current page query string with search and pagination state.

    Examples
    This example appends an icon to the column depending on the text being displayed in the cell.
    Note: This example assumes that field with ID 5 is NOT placed in the first column on the entry grid. This hook does not fire for the first column in the grid. Look at gform_entries_first_column to add content to the first column.
    add_action( 'gform_entries_column', 'add_icon', 10, 5 );
    function add_icon( $form_id, $field_id, $value, $entry, $query_string ) {

    //targeting form 190 only.
    if ( $form_id != 190 )
    return;

    //targeting field 5 only
    if ( $field_id != 5 )
    return;

    if ( $value == 'yes' ) {
    echo " ";
    } elseif ( $value == 'no' ) {
    echo " ";
    }
    }

    Source Code
    This action hook is located in GFEntryList::leads_page() in entry_list.php.

    gform_entries_column_filter

    gform_entries_column_filter

    DescriptionUsageParametersExamplesPlacementSource Code

    Description
    Use this filter to inject markup and replace the value of any non-first column in the entry list grid.
    Usage
    add_filter( 'gform_entries_column_filter', 'change_column_data', 10, 5 );

    Parameters

    $value string
    Current value that will be displayed in this cell.

    $form_id integer
    ID of the current form.

    $field_id integer
    ID of the field that this column applies to.

    $entry Entry Object
    Current entry object.

    $query_string string
    Current page query string with search and pagination state.

    Examples
    This example replaces the value when the field id is 2 and the form id is 1. Note: This example assumes that field with ID 2 is NOT placed in the first column on the entry grid. This hook does not fire for the first column in the grid. Look at gform_entries_first_column to add content to the first column.
    add_filter( 'gform_entries_column_filter', 'change_column_data', 10, 5 );
    function change_column_data( $value, $form_id, $field_id, $entry, $query_string ) {
    //only change the data when form id is 1 and field id is 2
    if ( $form_id != 1 && $field_id != 2 ) {
    return $value;
    }
    return "newdata";
    }

    This example displays text next to the existing value.
    add_filter( 'gform_entries_column_filter', 'change_column_data', 10, 5 );
    function change_column_data( $value, $form_id, $field_id, $entry, $query_string ) {
    //only change the data when form id is 1 and field id is 2
    if ( $form_id != 1 && $field_id != 2 ) {
    return $value;
    }
    return $value . " - newdata";
    }

    Placement
    This code should be placed in the functions.php file of your active theme.
    Source Code
    This hook is located in GFEntryList::leads_page() in entry_list.php.

    gform_enqueue_scripts

    gform_enqueue_scripts

    DescriptionUsageParametersExamples1. Enqueue custom script2. Dequeue stylesheets3. Manually include RTL stylesheet4. Dequeue scriptPlacementSource Code

    Description
    This filter is executed during the process of enqueuing scripts for each form in the current page. When developing custom field types that require extra scripts, this hook should be used to enqueue the custom scripts when appropriate.
    Usage
    1add_action( 'gform_enqueue_scripts', 'your_function_name', 10, 2 );
    You can also specify this per form by adding the form id after the hook name.
    1add_action( 'gform_enqueue_scripts_6', 'your_function_name', 10, 2 );

    Parameters

    $form Form Object
    The current form object.

    $is_ajax bool
    Specify if the form is configured to be submitted via AJAX.

    Examples
    1. Enqueue custom script
    This example enqueues a custom script for all AJAX forms.
    123456add_action( 'gform_enqueue_scripts', 'enqueue_custom_script', 10, 2 );function enqueue_custom_script( $form, $is_ajax ) {    if ( $is_ajax ) {        wp_enqueue_script( 'custom_script', 'path/file.js' );    }}
    2. Dequeue stylesheets
    This example shows how you can dequeue the stylesheets for a specific form.
    12345678add_action( 'gform_enqueue_scripts_1', 'dequeue_gf_stylesheets', 11 );function dequeue_gf_stylesheets() {    wp_dequeue_style( 'gforms_reset_css' );    wp_dequeue_style( 'gforms_datepicker_css' );    wp_dequeue_style( 'gforms_formsmain_css' );    wp_dequeue_style( 'gforms_ready_class_css' );    wp_dequeue_style( 'gforms_browsers_css' );}
    3. Manually include RTL stylesheet
    Gravity Forms will automatically include the RTL stylesheet if WordPress indicates an RTL language is in use. However, if you haven』t set the language yet and want to test with the RTL styles, you can use the following to include the stylesheet.
    12345add_action( 'gform_enqueue_scripts', 'enqueue_custom_script' );function enqueue_custom_script() {    $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || isset( $_GET['gform_debug'] ) ? '' : '.min';    wp_enqueue_style( 'gforms_rtl_css', GFCommon::get_base_url() . "/css/rtl{$min}.css", null, GFCommon::$version );}
    4. Dequeue script
    This example shows how you can dequeue a form script for a specific form.
    123add_action( 'gform_enqueue_scripts_1', function() {    wp_dequeue_script( 'gform_placeholder' );}, 11 );
    Placement
    This code should be placed in the header.php file of your active theme just before the wp_head() function call or a custom functions plugin.
    Source Code
    This filter is located in GFFormDisplay::enqueue_form_scripts() in form_display.php.

    gform_encrypt_password

    gform_encrypt_password

    DescriptionUsageParametersExamplesPlacementSinceSource Code

    Description
    Allows basic encryption of the password field.
    Usage
    1add_filter( 'gform_encrypt_password', 'your_function_name', 10, 3 );

    Parameters

    $encrypt_password bool
    Whether to encrypt the Password field with true or false. The default is false.

    $field Field Object
    The field object.

    $form Form Object
    The form object.

    Examples
    1add_filter( 'gform_encrypt_password', '__return_true' );
    1234567add_filter( 'gform_encrypt_password', 'encrypt_password', 10, 3 );function encrypt_password( $encrypt_password, $field, $form ){    if ( $form['id'] == 53 ){      $encrypt_password = true;    }    return $encrypt_password;}
    Placement
    This code should be placed in the functions.php file of your active theme.
    Since
    This filter was added in Gravity Forms version 1.8.9.
    Source Code
    This filter is located in GF_Field_Password::get_value_save_entry() in class-gf-field-password.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.