gform_entry_detail_url

gform_entry_detail_url

DescriptionUsageParametersExample(s)PlacementSinceSource Code

Description
The 「gform_entry_detail_url」 filter in Gravity Forms allows the entry_url placeholder to be modified to handle situations in which the wpurl might not match the admin_url.
Usage
1add_filter( 'gform_entry_detail_url', 'your_function_name', 10, 3 );

Parameters

$entry_url string
The Entry URL to filter.

$form Form Object
The current form object.

$entry Entry Object
The current entry object.

Example(s)
12345add_filter( 'gform_entry_detail_url', 'filter_url', 10, 3 );function filter_url( $entry_url, $form, $entry ){    $entry_url = str_replace('http://localhost', 'http://rocketgenius.com', $entry_url );    return $entry_url;}
Placement
Your code snippet should be placed in the functions.php file of your active theme.
Since
Gravity Forms Version 2.2.4
Source Code
This filter is located in GFCommon:replace_variables() in gravityforms/common.php.

gform_entry_meta

gform_entry_meta

DescriptionUsageParametersExamples1. Basic meta column2. Meta column with filters3. Quiz Add-On MetaPlacementSinceSource Code

Description
Use this hook to add custom properties to the Entry object. Allows entry meta data to be added as sortable columns to the entry list and export entries file.
Usage
add_filter( 'gform_entry_meta', 'custom_entry_meta', 10, 2);

Parameters

$entry_meta array
Entry meta array.

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

Examples
1. Basic meta column
add_filter( 'gform_entry_meta', 'custom_entry_meta', 10, 2 );
function custom_entry_meta( $entry_meta, $form_id ) {
// data will be stored with the meta key named score
// label - entry list will use Score as the column header
// is_numeric - used when sorting the entry list, indicates whether the data should be treated as numeric when sorting
// is_default_column - when set to true automatically adds the column to the entry list, without having to edit and add the column for display
// update_entry_meta_callback - indicates what function to call to update the entry meta upon form submission or editing an entry
$entry_meta['score'] = array(
'label' => 'Score',
'is_numeric' => true,
'update_entry_meta_callback' => 'update_entry_meta',
'is_default_column' => true
);

return $entry_meta;
}

function update_entry_meta( $key, $lead, $form ) {
//update score
$value = "5";
return $value;
}

2. Meta column with filters
add_filter( 'gform_entry_meta', function ( $entry_meta, $form_id ) {
$entry_meta['test'] = array(
'label' => 'Test',
'is_numeric' => false,
'update_entry_meta_callback' => 'update_entry_meta_test',
'is_default_column' => false,
'filter' => array(
'key' => 'test',
'text' => 'Test',
'operators' => array(
'is',
'isnot',
)
),
);

return $entry_meta;
}, 10, 2 );

function update_entry_meta_test( $key, $entry, $form ){
//update test
$value = "thisisatest";
return $value;
}

3. Quiz Add-On Meta
add_filter( 'gform_entry_meta', array( 'GFQuiz', 'entry_meta' ), 10, 2);
public static function entry_meta($entry_meta, $form_id){
$form = RGFormsModel::get_form_meta($form_id);
$quiz_fields = GFCommon::get_fields_by_type( $form, array( 'quiz' ) );
if ( false === empty ( $quiz_fields ) ) {
$entry_meta['gquiz_score'] = array(
'label' => 'Quiz Score Total',
'is_numeric' => true,
'update_entry_meta_callback' => array('GFQuiz', 'update_entry_meta')
);
$entry_meta['gquiz_grade'] = array(
'label' => 'Quiz Grade',
'is_numeric' => false,
'update_entry_meta_callback' => array('GFQuiz', 'update_entry_meta')
);
$entry_meta['gquiz_percent'] = array(
'label' => 'Quiz Percentage',
'is_numeric' => true,
'update_entry_meta_callback' => array('GFQuiz', 'update_entry_meta')
);
$entry_meta['gquiz_is_pass'] = array(
'label' => 'Quiz Pass/Fail',
'is_numeric' => false,
'update_entry_meta_callback' => array('GFQuiz', 'update_entry_meta')
);
}
return $entry_meta;
}
public static function update_entry_meta($key, $lead, $form){
$value = "";
$results = self::get_quiz_results( $form, $lead, false );
if ( $key == "gquiz_score" )
$value = $results["score"];
elseif ( $key == "gquiz_percent" )
$value = $results["percent"];
elseif ( $key == "gquiz_grade" )
$value = $results["grade"];
elseif ( $key == "gquiz_is_pass" )
$value = $results["is_pass"] ? "1" : "0";
return $value;
}

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.7.
Source Code
This action hook is located in GFFormsModel::get_entry_meta() in forms_model.php.

gform_entry_detail

gform_entry_detail

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this action hook to add extra text to the Entry detail page after the entry details are displayed and before Notes (if visible).
Usage
add_action( 'gform_entry_detail', 'add_to_details', 10, 2 );

Parameters

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

$entry Entry Object
The current entry.

Examples
This example displays the listed text on all entries for form id 31 when viewing the Entry details.
add_action( 'gform_entry_detail', 'add_to_details', 10, 2 );
function add_to_details( $form, $entry ) {
if ( $form['id'] == 31 ) {
echo '

This hook is used to add additional information to the details page for an entry.

';
}
}

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_entry_page_size

gform_entry_page_size

DescriptionUsageParametersExamplesSource Code

Description
Use this filter modify how many entries are shown per page in the Entry List view.
Usage
The base filter which would run for all forms would be used like so:
add_filter( 'gform_entry_page_size', 'your_function_name', 10, 2 );

To target a specific form append the form id to the hook name. (format: gform_entry_page_size_FORMID)
add_filter( 'gform_entry_page_size_10', 'your_function_name', 10, 2 );

Parameters

$page_size integer
The number of entries to show per page.

$form_id integer
The current form ID.

Examples
This example demonstrates how to set the entry page size. Let』s set it to show 40 entries per page.
add_filter( 'gform_entry_page_size', 'my_entry_page_size' );
function my_entry_page_size() {
return 40;
}

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

gform_entry_list_bulk_actions

gform_entry_list_bulk_actions

DescriptionUsageParametersExample(s)PlacementSinceSource Code

Description
The 「gform_entry_list_bulk_actions」 filter in Gravity Forms allows the drop down of available bulk actions on the entries list to be modified. This filter works well with the gform_entry_list_action action for handling the custom actions added.
Usage
The following would apply to all forms:
1add_filter( 'gform_entry_list_bulk_actions', 'your_function_name', 10, 2 );
To limit the scope of your function to a specific form, append the form id to the end of the hook name. (format:gform_entry_list_bulk_actions_FORMID)
1add_filter( 'gform_entry_list_bulk_actions_21', 'your_function_name', 10, 2 );

Parameters

$actions array
An array of the bulk actions to be used in the drop down list.

$form_id int
The ID of the current form.

Example(s)
12345add_filter( 'gform_entry_list_bulk_actions_21', 'add_actions', 10, 2 );function add_actions( $actions, $form_id ){    $actions['my_custom_action'] = 'My Custom Action';    return $actions;}
Placement
Your code snippet should be placed in the functions.php file of your active theme.
Since
Gravity Forms Version 2.2.4.
Source Code
This filter is located in the GF_Entry_List_Table::get_bulk_actions() in gravityforms/entry_list.php.

gform_entry_field_value

gform_entry_field_value

DescriptionUsageParametersExamples1. Display category name2. Display choice label3. File UploadsAdditional NotesPlacementSource Code

Description
Use this filter to change the field』s value before getting displayed on the Entry detail page. Useful when creating custom field types that require special formatting when displayed,
Usage
add_filter( 'gform_entry_field_value', 'category_names', 10, 4 );

Parameters

$value string
The current entry value to be filtered.

$field Field Object
The field from which the entry value was submitted.

$entry Entry Object
The current entry.

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

Examples
1. Display category name
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_entry_field_value', 'category_names', 10, 4 );
function category_names( $value, $field, $lead, $form ) {

if ( $form['id'] != 104 || $field->id != 3 )
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_entry_field_value', function ( $value, $field, $entry, $form ) {
    $classes = array(
    'GF_Field_Checkbox',
    'GF_Field_MultiSelect',
    'GF_Field_Radio',
    'GF_Field_Select',
    );

    foreach ( $classes as $class ) {
    if ( $field instanceof $class ) {
    $value = $field->get_value_entry_detail( RGFormsModel::get_lead_field_value( $entry, $field ), $currency = '', $use_text = true, $format = 'html' );
    break;
    }
    }

    return $value;
    }, 10, 4 );

    3. File Uploads
    This example shows how you could display uploaded images in a Multi-File upload field.
    add_filter( 'gform_entry_field_value', function ( $value, $field, $entry, $form ) {
    if ( $field->get_input_type() == 'fileupload' && $field->multipleFiles && ! empty( $value ) ) { // Multi-File upload field
    $value = '';
    $raw_value = rgar( $entry, $field->id );
    $files = empty( $raw_value ) ? array() : json_decode( $raw_value, true );
    foreach ( $files as $file_url ) {
    $value .= sprintf( "
    ", $file_url, __( 'Click to view', 'gravityforms' ), $file_url );
    }
    }

    return $value;
    }, 10, 4 );

    And the following does the same for a single file upload field.
    add_filter( 'gform_entry_field_value', function ( $value, $field, $entry, $form ) {
    if ( $field->get_input_type() == 'fileupload' && ! empty( $value ) ) { // Single file upload field
    $file_url = rgar( $entry, $field->id );
    $value = sprintf( "
    ", $file_url, __( 'Click to view', 'gravityforms' ), $file_url );
    }

    return $value;
    }, 10, 4 );

    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).
    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_grid() in entry_detail.php.

    gform_entry_post_save

    gform_entry_post_save

    DescriptionUsageParametersExamples1. Temporarily change field value2. Change Entry PropertyPlacementSource Code

    Description
    Use this filter to perform actions right after an entry has been saved. This fires before notifications are sent and before the confirmation is processed.
    Usage
    add_filter( 'gform_entry_post_save', 'post_save', 10, 2 );

    Parameters

    $entry Entry Object
    The current entry.

    $form Form Object
    The current form.

    Examples
    1. Temporarily change field value
    This example appends the text 「testing」 to the value of field 1 in the lead. This new value will be available for use in notifications and confirmations, but the updated text is NOT saved with the entry.
    add_filter( 'gform_entry_post_save', 'post_save', 10, 2 );
    function post_save( $entry, $form ) {
    $entry['1'] = rgar( $entry, '1' ) . ' testing';
    return $entry;
    }

    2. Change Entry Property
    This example shows how you can change an entry property such as the 『source_url』 and save the change.
    add_filter( 'gform_entry_post_save', function ( $entry ) {
    $entry['source_url'] = 'the new url here';
    GFAPI::update_entry_property( $entry['id'], 'source_url', $entry['source_url'] );

    return $entry;
    } );

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

    This filter is located in GFFormDisplay::handle_submission() in form_display.php.

    gform_entry_list_column_input_label_only

    gform_entry_list_column_input_label_only

    DescriptionUsageParametersExamplesInclude Product Field LabelPlacementSource CodeSince

    Description
    This filter can be used to override the default behavior of only including the input label in the entry list column header.
    Usage
    The base filter which would run for all forms and all fields would be used like so:
    add_filter( 'gform_entry_list_column_input_label_only', 'your_function_name', 10, 3 );

    Parameters

    $input_label_only bool
    Should the label only include the input label.

    $form Form Object
    The form currently being processed.

    $field Field Object
    The field currently being processed.

    Examples
    Include Product Field Label
    This example shows how you can also include the field label along with the choice label.
    add_filter( 'gform_entry_list_column_input_label_only', function ( $input_label_only, $form, $field ) {
    return $field->type == 'product' ? false : $input_label_only;
    }, 10, 3 );

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

    This filter is located in GFFormsModel::get_grid_columns() in forms_model.php.
    Since
    This filter was added in Gravity Forms 1.9.3.

    gform_entry_id_pre_save_lead

    gform_entry_id_pre_save_lead

    DescriptionUsageParametersExamplesSource Code

    Description
    Allows entry id to be changed before submission is saved. Useful to update an existing entry instead of creating a new one.
    Usage
    Apply to all forms.
    add_filter( 'gform_entry_id_pre_save_lead', 'my_update_entry_on_form_submission', 10, 2 );

    Apply to a specific form.
    add_filter( 'gform_entry_id_pre_save_lead_10', 'my_update_entry_on_form_submission', 10, 2 );

    Parameters

    $entry_id integer
    Default value is null.

    $form Form Object
    The current form.

    Examples
    This example demonstrates how to use to this hook to retrieve an entry ID from the $_POST data and return it here so the existing entry is updated rather than a new entry created.
    This assumes that the entry ID to be updated has been submitted with the form from an input which as the input name 「my_update_entry_id」. You can store it in any input, but you will need to update the input name used when you retrieve the value via the rgpost() function.
    add_filter( 'gform_entry_id_pre_save_lead', 'my_update_entry_on_form_submission', 10, 2 );
    function my_update_entry_on_form_submission( $entry_id, $form ) {
    $update_entry_id = rgpost( 'my_update_entry_id' );
    return $update_entry_id ? $update_entry_id : $entry_id;
    }

    Source Code
    This filter is located in GFFormDisplay::handle_submission() in form_display.php.