gform_mailchimp_keep_existing_groups

gform_mailchimp_keep_existing_groups

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this filter to modify whether a user that is already subscribed to your list has their groups replaced when submitting the form a second time. By default, the original groups are kept and any new ones are added.
Usage
add_filter( 'gform_mailchimp_keep_existing_groups', '__return_false' );

You can also specify this per form by adding the form id after the hook name.
add_filter( 'gform_mailchimp_keep_existing_groups_1', '__return_false' );

Parameters
There are no parameters.
Examples
This examples returns false so that the groups are replaced.
add_filter( 'gform_mailchimp_keep_existing_groups', '__return_false' );

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in class-gf-mailchimp.php.

gform_mailchimp_field_value

gform_mailchimp_field_value

DescriptionUsageParametersExamples1. Format Birthday2. Format SignaturePlacementSinceSource Code

Description
Use this filter to modify a value before it is sent to the Mailchimp API.
Usage
The base filter which would run for all forms and all fields would be used like so:
add_filter( 'gform_mailchimp_field_value', 'your_function_name', 10, 5 );

To target a specific form append the form id to the hook name. (format: gform_mailchimp_field_value_FORMID)
add_filter( 'gform_mailchimp_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_mailchimp_field_value_FORMID_FIELDID)
add_filter( 'gform_mailchimp_field_value_10_3', 'your_function_name', 10, 4 );

Parameters

$value string
The value to be modified.

$form_id integer
The ID of the form being processed.

$field_id string
The ID of the field being processed.

$entry Entry Object
The entry currently being processed.

$merge_var_name string
The name of the mapped Mailchimp MMERGE field.

Examples
1. Format Birthday
This example takes the birthday and reformats it into mm/dd before sending. This time we』re using the form id and field id in the filter name to target only field id 3 in form id 10.
add_filter( 'gform_mailchimp_field_value_10_3', 'change_birthday', 10, 4 );
function change_birthday( $value, $form_id, $field_id, $entry ) {
// Skip processing if $value is empty.
if ( empty( $value ) ) {
return $value;
}
$month = date( 'm', strtotime( $value ) ); //get month
$day = date( 'd', strtotime( $value ) ); //get day
$date = $month . '/' . $day; //build date into format needed by Mailchimp
return $date;
}

2. Format Signature
add_filter( 'gform_mailchimp_field_value', function ( $value, $form_id, $field_id, $entry, $merge_var_name ) {

return $merge_var_name == 'SIGNATURE' ? RGFormsModel::get_upload_url_root() . 'signatures/' . $value : $value;
}, 10, 5 );

Placement
This code should be placed in the functions.php file of your active theme.
Since
The base filter was added in version 2.0. The form and field specific versions were added in version 3.7.
Source Code
gf_apply_filters( 'gform_mailchimp_field_value', array( $form['id'], $field_id ), $field_value, $form['id'], $field_id, $entry, $this->merge_var_name )

This filter is located in GFMailChimp::maybe_override_field_value() in class-gf-mailchimp.php.

gform_mailchimp_allow_resubscription

gform_mailchimp_allow_resubscription

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this filter to modify whether a user that currently has a status of unsubscribed on your list is resubscribed. By default, the user is resubscribed.
Usage
add_filter("gform_mailchimp_allow_resubscription", "__return_false");

You can also specify this per form by adding the form id after the hook name.
add_filter("gform_mailchimp_allow_resubscription_1", "__return_false");

Parameters
There are no parameters.
Examples
This examples returns false so that users are not resubscribed:

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in mailchimp.php.

gform_{$SHORT_SLUG}_field_value

gform_{$SHORT_SLUG}_field_value

DescriptionShort Slug ValuesUsageParametersExamples1. ActiveCampaign – Use Choice Text Instead of Value2. ActiveCampaign – Replace Commas with Pipes3. Emma – Format Checkbox Field4. Help Scout – Change Value of Specific Field5. Zoho CRM – Format Date Field6. Zoho CRM – Format Checkbox FieldPlacementSinceSource Code

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 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 implements its own version of the hook:

gform_zapier_field_value

Usage
The base filter which would run for all forms and all fields would be used like so:
1add_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)
1add_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)
1add_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.
1234567891011add_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.
123456789101112add_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.
123456789add_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.
1234add_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.
123456789add_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.
1234567891011add_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 should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms 1.9.10.11.
Source Code
1234gf_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.

gform_logging_message

gform_logging_message

DescriptionParametersExamplePlacementSinceSource Code

Description
Use this filter to customize the messages sent to Gravity Forms logging. If the result returned is false, the message will not be logged. This is useful in multiple cases:

Sites which do not want to write logging to disk but rely on a separate logging framework or send to stdout via error_log.
Sites which want to customize the formatting or content of the logging messages.

Parameters

$message string
The current logging message.

$message_type string
The current logging message type.

$plugin_setting array
The logging setting for plugin.

$log object
The KLogger instance.

$GFLogging object
The Gravity Forms Logging object.

Example
This example shows how to override the default logging behavior in Gravity Forms and log all enabled Gravity Forms logging statements to your system』s error logs rather than the default Gravity Forms log files located within your WordPress install』s uploads directory.
12345add_filter( 'gform_logging_message', 'gform_debug_logging_stdout', 10, 5 );function gform_debug_logging_stdout( $message, $message_type, $plugin_setting, $log, $GFLogging ) {    error_log( $message );    return false;}
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms version 2.4.15
Source Code
This filter is located in GFLogging::log_message in logging.php:

gform_loaded

gform_loaded

DescriptionUsageParametersExamplesSource Code

Description
Triggered when Gravity Forms is loaded. Use this hook to initialize any functionality that depends on Gravity Forms.
Usage
1add_action( 'gform_loaded', 'my_function', 10, 0 );

Parameters
This action does not have any parameters.

Examples
1234function my_function() {    //Do something here}add_action( 'gform_loaded', 'my_function', 10, 0 );
Source Code
This action hook is located in gravityforms.php.

gform_load_form_settings

gform_load_form_settings

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter fires when the Form Settings page is loaded.
Usage
12345678

Parameters

event Event Object
Default JS event object.

form array
The current form object.

Examples
This example uses the gform_admin_pre_render filter to load the hook. Once the Forms Settings page is loaded a message is displayed if the form id is 44.
1234567891011121314add_action( 'gform_admin_pre_render', 'pre_render_function' );function pre_render_function( $form ) {    ?>        

gform_load_field_settings

gform_load_field_settings

DescriptionUsageParametersExamplesSource Code

Description
Fires on the Form Editor page after a field』s settings panel has been opened and settings have been displayed.
Usage
12345

Parameters

event Event Object
Default JS event object.

field array
The current field object.

form Form Object
The current form object.

Examples
This hook is primarily used in conjunction with the gform_field_standard_settings, gform_field_advanced_settings, and gform_editor_js hooks.
The gform_field_standard_settings and gform_field_advanced_settings hooks are responsible for displaying custom field setting UI. These hooks are typically used in conjunction with the gform_editor_js hook to output any JS required by the custom settings UI. As part of this process, the gform_load_field_settings JS hook can be used in the gform_editor_js PHP hook, to only perform certain actions once the field settings have loaded.
Source Code
This filter is located in gravityforms.js

gform_load_field_choices

gform_load_field_choices

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
This JavaScript hook allows help text to be displayed below the choices in the Form Editor.
Note: This hook in used in the Gravity Forms Quiz and Survey add-ons.
Usage
12345gform.addAction('gform_load_field_choices', function (field)   {      //do something  });

Parameters

field Field Object
The current field.

Examples
This example uses the gform_admin_pre_render action to load the hook.
1234567891011121314add_action( 'gform_admin_pre_render', 'pre_render_function' );function pre_render_function( $form ) {    ?>