gform_name_first

gform_name_first

DescriptionUsageParametersExamplesSource Code

Description
This filter is executed when creating the first name field and can be used to modify the 「First」 label.
Usage
add_filter( 'gform_name_first', 'change_first', 10, 2 );

Parameters

$label string
The label to be filtered.

$form_id integer
The id of the current form.

Examples
This example changes the default first name label:
add_filter( 'gform_name_first', 'change_first', 10, 2 );
function change_first( $label, $form_id ) {
return "First Name";
}

Source Code
This filter is located in js.php and GF_Field_Name::get_field_input() in includes/fields/class-gf-field-name.php.

gform_multiselect_placeholder

gform_multiselect_placeholder

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this filter to change the default 「Click to select…」 placeholder text on Multi Select fields that use the enhanced user interface.
Usage
add_filter( 'gform_multiselect_placeholder', 'your_function_name', 10, 2 );

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

From 1.9.13.19 you can also target a specific field by appending both the form id and the field id to the hook name. (format: gform_multiselect_placeholder_FORMID_FIELDID)
add_filter( 'gform_multiselect_placeholder_6_3', 'your_function_name', 10, 2 );

Parameters

$placeholder string
The placeholder to be filtered.

$form_id integer
ID of current form.

$field Field Object
The field currently being rendered. Available from 1.9.13.19.

Examples
This example changes the placeholder text to 「Click to select your options…」
add_filter( 'gform_multiselect_placeholder_185', 'set_multiselect_placeholder', 10, 2 );
function set_multiselect_placeholder( $placeholder, $form_id ) {
return 'Click to select your options...';
}

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

gform_multifile_upload_field

gform_multifile_upload_field

DescriptionUsageParametersExample(s)PlacementSinceSource Code

Description
The 「gform_multifile_upload_field」 filter in Gravity Forms is used to filter the field object that will be associated with the uploaded file. This is useful when you want to use Gravity Forms upload system to upload files. Using this filter you can return a one-time-use field object to process the file as desired.
Usage
The following would apply to all forms:
add_filter( 'gform_multifile_upload_field', 'your_function_name', 10, 3 );

To target a specific form, append the form id to the hook name. (format: gform_multifile_upload_field_FORMID)
add_filter( 'gform_multifile_upload_field_21', 'your_function_name', 10, 3 );

To target a specific form and field, append the form id and field id to the hook name. (format: gform_multifile_upload_field_FORMID_FIELDID)
add_filter( 'gform_multifile_upload_field_21_3', 'your_function_name', 10, 3 );

Parameters

$field Field Object
The current field.

$form Form Object
The current form.

$field_id int
The current field id.

Example(s)
add_filter( 'gform_multifile_upload_field', 'create_custom_file_upload_field', 10, 3 );

function create_custom_file_upload_field( $field, $form, $field_id ) {
$field = new GF_Field_FileUpload( array(
'id' => $field_id,
'multipleFiles' => true,
'maxFiles' => 1,
'maxFileSize' => '',
'allowedExtensions' => 'csv'
) );

return $field;
}

Placement
Your code snippet should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms Version 2.2.2.
Source Code
This filter is located in GFAsyncUpload::upload in gravityforms/upload.php.

gform_mollie_payment_methods

gform_mollie_payment_methods

DescriptionUsageParametersPlacementSinceSource Code

Description
Filter the Mollie payment methods.
Usage
1add_filter( 'gform_mollie_payment_methods', 'your_function_name', 10, 1 );
Parameters

$methods array
The payment methods.

Placement
This code should be placed in the functions.php file of your active theme.
Since
Added in Mollie 1.0
Source Code
1$methods = apply_filters( 'gform_mollie_payment_methods', $methods );
This hook is located in GF_Mollie::get_methods() in class-gf-mollie.php.

gform_mollie_payment_method_label

gform_mollie_payment_method_label

DescriptionUsageParametersPlacementSinceSource Code

Description
Modify the Payment Method label when creating a Mollie field.
Usage
Applies to all forms:
add_filter( 'gform_mollie_payment_method_label', 'your_function_name', 10, 2 );

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

Parameters

$label string
The label to be filtered..

$form_id int
The current form ID.

Placement
This code should be placed in the functions.php file of your active theme.
Since
Added in Mollie 1.0
Source Code
json_encode( gf_apply_filters( array( 'gform_mollie_payment_method_label', rgget( 'id' ) ), esc_html__( 'Payment Method', 'gravityformsmollie' ), rgget( 'id' ) ) ), $default_payment_method ) . PHP_EOL;

This hook is located in GF_Field_Mollie::get_form_editor_inline_script_on_page_render() in class-gf-field-mollie.php.

gform_mollie_payment_description

gform_mollie_payment_description

DescriptionUsageParametersExamples1. Remove the entry ID2. Include a field valuePlacementSinceSource Code

Description
Allow for the filtering of the payment description.
Usage
add_filter( 'gform_mollie_payment_description', 'your_function_name', 10, 5 );

Parameters

$description string
The payment description.
$description = 'Entry ID: 123, Products: Product A, Product B, Product C';

$strings array
Contains the Entry ID and Products. The array which was imploded to create the description.
$strings = array(
'entry_id' => 'Entry ID: 123',
'products' => 'Products: Product A, Product B, Product C',
);

$entry array
The entry object currently being processed.

$submission_data Submission Data
Contains the form title, payment amount, setup fee amount, trial amount, line items created using the submitted pricing field values and any discounts from coupons.

$feed array
The feed object currently being processed.

Examples
1. Remove the entry ID
The following example shows how you can remove the entry ID from the description.
add_filter( 'gform_mollie_payment_description', 'remove_entry_id', 10, 2 );
function remove_entry_id( $description, $strings ) {
unset( $strings['entry_id'] );

return implode( ', ', $strings );
}

2. Include a field value
The following example shows how you can append the value of a form field to the description.
add_filter( 'gform_mollie_payment_description', 'append_field_value', 10, 3 );
function append_field_value( $description, $strings, $entry ) {

return $description . ', Name: ' . rgar( $entry, '1.3' ) . ' ' . rgar( $entry, '1.6' );
}

Placement
This code should be placed in the functions.php file of your active theme.
Since
Added in Mollie 1.0
Source Code
apply_filters( 'gform_mollie_payment_description', $description, $strings, $entry, $submission_data, $feed );

This hook is located in GF_Mollie::get_payment_description() in class-gf-mollie.php.

gform_mollie_components_object

gform_mollie_components_object

DescriptionUsageParametersPlacementSinceSource Code

Description
Modify Mollie Components object when displaying Mollie Field.
Usage
add_filter( 'gform_mollie_components_object', 'your_function_name', 10, 2 );

Parameters

$args array
Mollie components object.

$form_id int
Current form ID.

Placement
This code should be placed in the functions.php file of your active theme.
Since
Added in Mollie 1.0
Source Code
$args = apply_filters( 'gform_mollie_components_object', $args, $form['id'] );

This hook is located in GF_Mollie::register_init_scripts() in class-gf-mollie.php.

gform_merge_tag_value_pre_calculation

gform_merge_tag_value_pre_calculation

DescriptionUsageJavaScript VersionParametersExamplePlacementSource CodePHP VersionParametersExamplePlacementSource Code

Description
This filter can be used to modify the value returned by a field merge tag before it is used by a number field calculation or calculated product field.
Usage
The gform_merge_tag_value_pre_calculation filter has both a JavaScript version and a PHP version. Both versions should be used.
The JavaScript version only overrides the merge tag value on the front-end.
12345gform.addFilter( 'gform_merge_tag_value_pre_calculation', function( value, mergeTagArr, isVisible, formulaField, formId ) {    // do stuff     return result;} );
The PHP version overrides the merge tag value when the calculation is rerun during submission using the field values saved in the entry.
12345add_filter( 'gform_merge_tag_value_pre_calculation', function( $value, $input_id, $modifier, $field, $form, $entry ) {    // do stuff     return $result;}, 10, 5 );
JavaScript Version

Parameters

value float
The field value after the merge tag was processed.

mergeTagArr array
The merge tag being processed.
mergeTagArr[0] contains the full merge tag e.g. {Field label:ID:modifier}
mergeTagArr[1] contains the field or input ID e.g. 2
mergeTagArr[3] contains the modifier(s) including the colon e.g. :value
mergeTagArr[4] contains the modifier(s) without the colon e.g. value

isVisible boolean
Is the field referenced in the merge tag visible or hidden by conditional logic?

formulaField Javascript Object
The current calculation field object. e.g.
1{"field_id":3,"formula":"{:1}+{:2}","rounding":""}

formId integer
The ID of the form in use.

Example
This example shows how you can enable the :value modifier for use with choice based pricing fields.
1234567891011121314151617181920212223242526gform.addFilter('gform_merge_tag_value_pre_calculation', function (value, mergeTagArr, isVisible, formulaField, formId) {     var inputId = mergeTagArr[1],        fieldId = parseInt(inputId),        modifier = mergeTagArr[4],        field = jQuery('#field_' + formId + '_' + fieldId);     if (modifier == 'value' && field.hasClass('gfield_price') && isVisible) {        var input = field.find('input[name="input_' + inputId + '"], select[name="input_' + inputId + '"]');         // filter out unselected radio or checkbox inputs        if (input.length > 1 || input.prop('type') == 'checkbox') {            input = input.filter(':checked');        }         if (input.length > 0) {            var val = input.val().split('|');            if (val.length > 1) {                value = val[0];            }        }     }     return value;});
Placement
Your code snippet can be placed in a HTML field on your form or in a theme custom JavaScript file.
Source Code
This filter is located in js/gravityforms.js
PHP Version

Parameters

$value float
The field value after the merge tag was processed.

$input_id string
The field or input ID from the merge tag.

$modifier string
The modifier from the merge tag e.g. value.

$field Field Object
The calculation field currently being processed.

$form Form Object
The form currently being processed.

$entry Entry Object
The entry currently being processed.

Example
This example shows how you can enable the :value modifier for use with choice based pricing fields.
12345678910add_filter( 'gform_merge_tag_value_pre_calculation', function ( $value, $input_id, $modifier, $field, $form, $entry ) {    if ( $modifier == 'value' ) {        $value = GFCommon::to_number( GFCommon::replace_variables( "{:{$input_id}:value}", $form, $entry ) );        if ( ! $value || ! is_numeric( $value ) ) {            $value = 0;        }    }     return $value;}, 10, 6 );
Placement
Your code snippet should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFCommon::calculate() in common.php

gform_merge_tag_list_exclude

gform_merge_tag_list_exclude

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this filter to exclude field types from the merge tag drop-downs that are displayed throughout the admin pages.
Usage
1add_filter( 'gform_merge_tag_list_exclude', 'exclude_hidden', 10, 3 );
Parameters

$excluded_fields array
Array to be filtered. Contains a list of field types that will be excluded from the merge tag drop down

$element_id string
HTML ID attribute of the merge tag drop-down.

$fields array
Array containing all form Field Object

Examples
This example adds a message below the currency drop down.
1234add_filter( 'gform_merge_tag_list_exclude', 'currency_message', 10, 3 );function currency_message( $message ) {    return 'US Dollars is the only supported currency by this payment gateway.';}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFCommon::insert_variables() in common.php

gform_merge_tag_filter

gform_merge_tag_filter

DescriptionUsageParametersExamples1. Exclude fields2. Add an Address field modifier3. List field column4. Address field5. Date field6. File upload field7. :urlencode modifier8. Checkbox field :unchecked modifier9. :decode modifier10. Number field11. Age modifier12. Output Checkboxes field as listPlacementSinceSource Code

Description
Use this filter to dynamically change the merge tag output. Useful when filtering field types from being displayed in the {all_fields} merge tag, or implementing custom field types that require the merge tag output to be different from the value stored with the entry.
Usage
1add_filter( 'gform_merge_tag_filter', 'filter_merge_tag', 10, 6 );

Parameters

$value string
The current merge tag value to be filtered. Replace it with any other text to replace the merge tag output, or return 「false」 to disable this field』s merge tag output.

$merge_tag string
If the merge tag being executed is an individual field merge tag (i.e. {Name:3}), this variable will contain the field』s ID. If not, this variable will contain the name of the merge tag (i.e. all_fields).

$modifier string
The string containing any modifiers for this merge tag. For example, 「value,nohidden」 would be the modifiers for the following merge tag: {all_fields:value,nohidden}.

$field Field Object
The current field.

$raw_value Mixed
The raw value submitted for this field.

$format string
Whether the text is formatted as html or text.

Examples
1. Exclude fields
This example excludes any hidden fields from the {all_fields} merge tag as well as adds a placeholder text for the field whose ID is 2.
1234567891011add_filter( 'gform_merge_tag_filter', 'filter_all_fields', 10, 6 );function filter_all_fields( $value, $merge_tag, $modifier, $field, $raw_value, $format ) {     if ( $merge_tag == 'all_fields' && $field->type == 'hidden' ) {        return false;    } elseif ( $merge_tag == 'all_fields' && $field->id == '2' ) {        return 'Call us for details';    } else {        return $value;    }}
This example extends the default nohidden modifier to also exclude fields with the visibility setting set to hidden.
1234567add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value, $format ) {    if ( $merge_tag == 'all_fields' && $modifier == 'nohidden' && ( $field->type == 'hidden' || $field->visibility == 'hidden' ) ) {        return false;    }     return $value;}, 10, 6 );
2. Add an Address field modifier
This example adds a new modifier to the address field which replaces the field value with a map link. {Address:15:map_link}
123456789add_filter( 'gform_merge_tag_filter', 'address_map_link', 11, 6 );function address_map_link( $value, $merge_tag, $modifier, $field, $raw_value, $format ) {    if ( $field->type == 'address' && $merge_tag != 'all_fields' && $modifier == 'map_link' && ! empty( $raw_value ) ) {        $address_qs = GFCommon::implode_non_blank( ' ', $raw_value );        $address_qs = urlencode( $address_qs );        $value      = "Map It";    }    return $value;}
3. List field column
This example outputs a comma separated string containing the values for a specific column of a list field. The merge tag {list:10:2} would get the values for column 2 of field 10.
12345678910111213141516171819202122232425262728add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value, $format ) {    if ( $field->type == 'list' && $merge_tag != 'all_fields' && is_numeric( $modifier ) ) {        // count the actual number of columns        $choices      = $field->choices;        $column_count = count( $choices );         if ( $column_count > 1 ) {            // subtract 1 from column number as the choices array is zero based            $column_num = $modifier - 1;             // get the column label so we can use that as the key to the multi-column values            $column = rgars( $choices, "{$column_num}/text" );             // get the list fields values from the $entry            $values        = unserialize( $raw_value );            $column_values = array();             // loop through the rows and get only the column value we are interested in            foreach ( $values as $value ) {                $column_values[] = rgar( $value, $column );            }             $value = GFCommon::implode_non_blank( ', ', $column_values );        }    }     return $value;}, 10, 6 );
4. Address field
This shows how you can exclude the Address field from the merge tag output when using one of the country specific types and all the fields other five inputs are left empty by the user.
123456789101112131415add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $options, $field, $raw_value, $format ) {    if ( $field->type == 'address' ) {        if ( rgempty( $field->id . '.1', $raw_value )             && rgempty( $field->id . '.2', $raw_value )             && rgempty( $field->id . '.3', $raw_value )             && rgempty( $field->id . '.4', $raw_value )             && rgempty( $field->id . '.5', $raw_value )             && ! rgempty( $field->id . '.6', $raw_value )        ) {            return false;        }    }     return $value;}, 10, 6 );
5. Date field
This shows how you can reformat a date field value.
12345678add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $options, $field, $raw_value, $format ) {    if ( $field->type == 'date' ) {         return date_i18n( 'l jS F Y ', strtotime( $raw_value ) );    }     return $value;}, 10, 6 );
6. File upload field
This example shows how you can change the output of a single file upload field
123456789add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value, $format ) {    if ( $merge_tag != 'all_fields' && $field->type == 'fileupload' ) {        $value    = str_replace( ' ', '%20', $raw_value );        $pathinfo = pathinfo( $value );        $value    = rgar( $pathinfo, 'basename' );    }     return $value;}, 10, 6 );
7. :urlencode modifier
This example shows how you can implement a custom modifier which when found will cause the value to be urlencoded.
1234567add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value, $format ) {    if ( $merge_tag != 'all_fields' && $modifier == 'urlencode' ) {        $value = urlencode( $value );    }     return $value;}, 10, 6 );
8. Checkbox field :unchecked modifier
This example shows how you can implement a custom modifier which when found will return only the list of choices which were not selected when the form was submitted.
12345678910111213add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value, $format ) {   if ( $field->type == 'checkbox' && $modifier == 'unchecked' ) {      $value = array();      foreach ( $field->inputs as $input ) {         $input_value = rgar( $raw_value, $input['id'] );         $value[] = $input_value ? '' : $input['label'];      }       $value = GFCommon::implode_non_blank( ', ', $value );   }    return $value;}, 10, 6 );
9. :decode modifier
This example shows how you can implement a custom modifier which when found will convert any special HTML entities found in the value back to characters. Note: Bear in mind this filter only runs for form fields merge tags, so you can』t use this for other merge tags types ( e.g. {entry_url} ).
1234567add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value, $format ) {    if ( $merge_tag != 'all_fields' && $modifier == 'decode' ) {        $value = htmlspecialchars_decode( $value );    }     return $value;}, 10, 6 );
10. Number field
This example shows how you can change the output of a Number field by using the :value modifier with the field merge tag to return the raw unformatted value.
1234567add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value, $format ) {    if ( $merge_tag != 'all_fields' && $field->type == 'number' && $modifier == 'value' ) {        $value = $raw_value;    }     return $value;}, 10, 6 );
11. Age modifier
This example shows how you can implement a custom modifier which when found will return the age based on the date field value.
123456789add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value, $format ) {    if ( $field->type == 'date' && $modifier == 'age' ) {        $today = new DateTime();        $diff  = $today->diff( new DateTime( $raw_value ) );        $value = $diff->y;    }     return $value;}, 10, 6 );
12. Output Checkboxes field as list
This example shows how you can implement the custom modifier :list that when added to a checkboxes field merge tag will output the choices as an HTML list instead of the default comma separated values.
123456789101112131415161718192021add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value, $format ) {    if ( $field->type == 'checkbox' && $modifier == 'list' && ! empty( $raw_value ) ) {         $items = '';         foreach ( $raw_value as $key => $item ) {            if ( ! rgblank( $item ) ) {                        $items .= '

  • ' . wp_kses_post( GFCommon::selection_display( $item, $field, '', true ) ) . '
  • ';            }        }         if ( empty( $items ) ) {            $value = '';        } else {            $value = "

      $items

    ";        }     }     return $value;}, 10, 6 );
    Placement
    This code should be placed in the functions.php file of your active theme.
    Since

    $format parameter added in version 2.4.8.12.
    $raw_value parameter added in version 1.7.

    Source Code
    This filter is located in the following methods in common.php:

    GFCommon::replace_variables()
    GFCommon::get_submitted_fields()