bookmark_bordergform_addon_field_value

Description

This filter can be used to modify a value before it is sent to a third-party by one of the Add-on Framework based add-ons. If you want to filter the value for a specific add-on you can use gform_SLUG_field_value.

Usage

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

add_filter( 'gform_addon_field_value', 'your_function_name', 10, 5 );

To target a specific form append the form id to the hook name. (format: gform_addon_field_value_FORMID)

add_filter( 'gform_addon_field_value_10', 'your_function_name', 10, 5 );

To target a specific field append both the form id and the field id to the hook name. (format: gform_addon_field_value_FORMID_FIELDID)

add_filter( 'gform_addon_field_value_10_3', 'your_function_name', 10, 5 );

Parameters

  • $field_value string

    The value to be modified.

  • $form

    The Form currently being processed.

  • $entry Entry Object

    The Entry currently being processed.

  • $field_id string

    The ID of the Field currently being processed.

  • $slug string

    The Add-On slug, including the gravityforms prefix. See the Gravity Forms Add-On Slugs article for a list of possible slugs.

Examples

1. 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 any of the feed add-ons.

add_filter( 'gform_addon_field_value_10_3', function ( $field_value, $form, $entry, $field_id ) {

    return 'your new value';
}, 10, 4 );

2. 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_addon_field_value', 'gf_get_choice_text', 10, 5 );
function gf_get_choice_text( $field_value, $form, $entry, $field_id, $slug ) {
    $field = RGFormsModel::get_field( $form, $field_id );

    if ( is_object( $field ) && $field->type == 'survey' ) {
        $field_value = $field->get_value_export( $entry, $field_id, true );
    }

    return $field_value;
}

Placement

This code should be placed in the functions.php file of your active theme

Source Code

$field_value = gf_apply_filters( array( 'gform_addon_field_value', $form['id'], $field_id ), $field_value, $form, $entry, $field_id, $this->_slug );

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

Since

This filter was added in Gravity Forms 1.9.15.12.