gform_{$SHORT_SLUG}_field_value

Description

This filter exists for each of the Gravity Forms Add-Ons that use our Add-On Framework to send information to a third-party. It can be used to modify a value before you send it.

The filter name will actually include the short slug of the add-on in question, used in place of the {$SHORT_SLUG} placeholder. Refer to the section below for more information regarding short slug values.

If you want to filter the value for any add-on you can use gform_addon_field_value.

Short Slug Values

The Gravity Forms Add-On Slugs article lists the available short slugs to use with this hook:

The following add-ons listed in the slug article do not use the hook:

  • Gravity Forms CLI Add-On
  • Gravity Forms Debug Add-On
  • Gravity Forms Gutenberg Add-On

The Zapier Add-On versions 3.3 and earlier implement their own version of the filter:

For Zapier Add-On v4.0 and later use the gform_{$SHORT_SLUG}_field_value filter.

Usage

The base filter which would run for all forms and all fields would be used like so:

add_filter( 'gform_helpscout_field_value', 'your_function_name', 10, 4 );

To target a specific form append the form id to the hook name. (format: gform_{$SHORT_SLUG}_field_value_FORMID)

add_filter( 'gform_helpscout_field_value_10', 'your_function_name', 10, 4 );

To target a specific field append both the form id and the field id to the hook name. (format: gform_{$SHORT_SLUG}_field_value_FORMID_FIELDID)

add_filter( 'gform_helpscout_field_value_10_3', 'your_function_name', 10, 4 );

Parameters

  • $value string
    The value to be modified.
  • $form Form Object
    The form currently being processed.
  • $entry Entry Object
    The entry currently being processed.
  • $field_id string
    The ID of the field currently being processed.

Examples

1. ActiveCampaign – Use Choice Text Instead of Value

This example shows how you can replace the value of a choice based survey field with the choice text.

add_filter( 'gform_activecampaign_field_value', 'gf_get_choice_text', 10, 4 );
function gf_get_choice_text( $value, $form, $entry, $field_id ) {
    gf_activecampaign()->log_debug( __METHOD__ . '(): running.' );
    $field = GFAPI::get_field( $form, $field_id );

    if ( is_object( $field ) && $field->type == 'survey' ) {
        $value = $field->get_value_export( $entry, $field_id, true );
        gf_activecampaign()->log_debug( __METHOD__ . '(): Value: ' . $value );
    }
    return $value;
}

2. ActiveCampaign – Replace Commas with Pipes

This example shows how you can replace the commas used to separate checkbox or multi select choices with pipe characters.

add_filter( 'gform_activecampaign_field_value', 'gf_replace_commas_with_pipes', 10, 4 );
function gf_replace_commas_with_pipes( $value, $form, $entry, $field_id ) {
    gf_activecampaign()->log_debug( __METHOD__ . '(): running.' );
    $field = GFAPI::get_field( $form, $field_id );

    if ( is_object( $field ) && ( $field->type == 'checkbox' || $field->type == 'multiselect' ) ) {
        $value = str_replace( ', ', '||', $value );
        gf_activecampaign()->log_debug( __METHOD__ . '(): Value: ' . $value );
    }

    return $value;
}

3. Emma – Format Checkbox Field

This example shows how you can reformat the checkbox field value to be passed as an array instead of a string.

add_filter( 'gform_emma_field_value', function ( $value, $form, $entry, $field_id ) {
    $field = GFAPI::get_field( $form, $field_id );
    
    if ( is_object( $field ) && $field->get_input_type() === 'checkbox' ) {
        $value = explode( ', ', $value );
    }
    
    return $value;
}, 10, 4 );

4. Help Scout – Change Value of Specific Field

This example shows how you can change the value of field 3 on form 10 before it is passed to Help Scout.

add_filter( 'gform_helpscout_field_value_10_3', function ( $value, $form, $entry, $field_id ) {
    return 'your new value';
}, 10, 4 );

5. Zoho CRM – Format Date Field

This example shows how you can reformat the entry date from yyyy-mm-dd to the format configured on the field.

add_filter( 'gform_zohocrm_field_value', function ( $value, $form, $entry, $field_id ) {
    $field = GFAPI::get_field( $form, $field_id );
    
    if ( is_object( $field ) && $field->type == 'date' ) {
        $value = GFCommon::date_display( $value, $field->dateFormat );
    }
    
    return $value;
}, 10, 4 );

6. Zoho CRM – Format Checkbox Field

This example shows how you can reformat the checkbox field value to pass true or false instead of the choice. This snippet is not needed if you’re using version 1.8 of the add-on or newer.

add_filter( 'gform_zohocrm_field_value', function ( $value, $form, $entry, $field_id ) {
    gf_zohocrm()->log_debug( __METHOD__ . '(): Running...' );
    $field = GFAPI::get_field( $form, $field_id );
    
    if ( is_object( $field ) && $field->get_input_type() === 'checkbox' ) {
    gf_zohocrm()->log_debug( __METHOD__ . '(): Checkbox value to true or false.' );
    $value = $value ? 'true' : 'false';
    }
    
    return $value;
}, 10, 4 );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Since

This filter was added in Gravity Forms 1.9.10.11.

Source Code

gf_apply_filters( "gform_{$slug}_field_value", array(
    $form['id'],
    $field_id
), $field_value, $form, $entry, $field_id );

This filter is located in GFAddOn::maybe_override_field_value() in includes/addon/class-gf-addon.php.