gform_aweber_post_subscriber_created

gform_aweber_post_subscriber_created

DescriptionUsageParametersExamples1. Store a property in the entry metaPlacementSinceSource Code

Description
The gform_aweber_post_subscriber_created hook can be used to perform custom actions after the subscriber has been successfully added to the AWeber list.
Usage
The hook which would run for all AWeber feeds can be used like so:
add_filter( 'gform_aweber_post_subscriber_created', 'your_function_name', 10, 4 );

Parameters

$subscriber array
An associative array containing the subscriber properties returned by AWeber in the response to the create request.

$form Form Object
The Form which is currently being processed.

$entry Entry Object
The Entry which is currently being processed.

$feed Feed Object
The Feed which is currently being processed.

Examples
1. Store a property in the entry meta
The following example shows how you can store the value from one of the subscriber properties in the entry meta.
add_action( 'gform_aweber_post_subscriber_created', function ( $subscriber, $form, $entry, $feed ) {
gform_update_meta( $entry['id'], 'aweber_subscriber_status', rgar( $subscriber, 'status' ) );
}, 10, 4 );

Placement
Your code snippet should be placed in the functions.php file of your active theme.
Since
This hook was added in AWeber version 2.4.1.
Source Code
This filter is located in GFAWeber::export_feed() in class-gf-aweber.php.

gform_campfire_message

gform_campfire_message

DescriptionUsageParametersExamples1. All feeds2. Specific feedPlacementSource Code

Description
This filter is used to dynamically alter the message before it is sent to Campfire.
Usage
The following would apply to all feeds:
add_filter( 'gform_campfire_message', 'your_function_name', 10, 4 );

To target feeds for a specific form append the form id to the hook name. (format: gform_campfire_message_FORMID)
add_filter( 'gform_campfire_message_4', 'your_function_name', 10, 4 );

Parameters

$message string
The message to be sent to Campfire.

$feed Feed Object
The feed currently being processed.

$entry Entry Object
The entry currently being processed.

$form Form Object
The form currently being processed.

Examples
1. All feeds
This example shows how you can change the message.
add_filter( 'gform_campfire_message', 'change_message', 10, 4 );
function change_message( $message, $feed, $entry, $form ) {

return 'your new message';
}

2. Specific feed
This example shows how you can change the message for a specific feed.
add_filter( 'gform_campfire_message_4', 'change_another_message', 10, 4 );
function change_another_message( $message, $feed, $entry, $form ) {
if ( rgars( $feed, 'meta/feedName' ) == 'Campfire Feed 2' ) {
$message = 'your new message';
}

return $message;
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
gf_apply_filters( 'gform_campfire_message', $form['id'], rgars( $feed, 'meta/message' ), $feed, $entry, $form )

This filter is located in GFCampfire::process_feed() in class-gf-campfire.php.

gform_calculation_format_result

gform_calculation_format_result

DescriptionUsageParametersExamplesFormat the number field with id 1 as currency.Show always two decimals.PlacementSource Code

Description
The 「gform_calculation_format_result」 filter can be used to override the default formatting for a calculated result.
Usage
The gform_calculation_result filter is a JavaScript filter.
gform.addFilter( 'gform_calculation_format_result', function( result, formulaField, formId, calcObj ) {
// do stuff

return result;
} );

Parameters

result float
The calculation result.

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

formId integer
The ID of the form in use.

calcObj Javascript Object
The calculation object.

Examples
Format the number field with id 1 as currency.

Show always two decimals.

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.

gform_before_delete_field

gform_before_delete_field

DescriptionUsageParametersExamplesSource Code

Description
Use this action hook to perform actions right before a field is deleted from a form.
Usage
add_action( 'gform_before_delete_field', 'do_cleanup', 10, 2 );

Parameters

$form_id integer
ID of current form.

$field_id integer
ID of deleted field.

Examples
This example adds a log file entry when a field is deleted.
add_action( 'gform_before_delete_field', 'log_field_deleted', 10, 2 );
function log_field_deleted( $form_id, $field_id ) {
$log_file = ABSPATH . '/gf_deleted_fields.log';
$f = fopen( $log_file, 'a' );
$user = wp_get_current_user();
$form = GFAPI::get_form( $form_id );
$field = RGFormsModel::get_field( $form, $field_id );

fwrite( $f, date( 'c' ) . " - Field deleted by {$user->user_login}. Form ID: {$form_id}. Field: {$field["label"]} (ID: {$field_id}) n" );
fclose( $f );
}

Source Code
This action hook is located in GFFormsModel::delete_field() in form_model.php.

gform_capsulecrm_case

gform_capsulecrm_case

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
This filter allows the Capsule CRM Case object to be modified before it is created.
Usage
The following would apply to all forms:
add_filter( 'gform_capsulecrm_case', 'your_function_name', 10, 4 );

To target a specific form, append the form id to the hook name. (format: gform_capsulecrm_case_FORMID)
add_filter( 'gform_capsulecrm_case_1', 'your_function_name', 10, 4 );

To target a specific feed for a form, append the form id and feed id to the hook name. (format: gform_capsulecrm_case_FORMID_FEEDID)
add_filter( 'gform_capsulecrm_case_1_7', 'your_function_name', 10, 4 );

Parameters

$case array
Capsule CRM case.
array (
'name' => 'Capsule CRM',
'description' => 'Test Case',
'status' => 'OPEN',
'party' =>
array (
'id' => 179884585,
'owner' =>
array (
'username' => 'testuser'
)
)
)

$form Form Object
The current form.

$entry Entry Object
The current entry.

$feed Feed Object
The current feed.

Examples
add_filter( 'gform_capsulecrm_case', 'change_case_object', 10, 4 );
function change_case_object( $case, $form, $entry, $feed ){
$case['description'] = 'Created by API';
return $case;
}

Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms Capsule CRM Add-On version 1.2.
Source Code
This filter is located in GFCapsuleCRM::create_case() in class-gf-capsulecrm.php.

gform_calculation_formula

gform_calculation_formula

DescriptionUsageJavaScript VersionParametersJS ExamplePlacementSource CodePHP VersionParametersPHP ExamplePlacementSource Code

Description
This filter can be used to dynamically modify the formula of a number field calculation or calculated product field.
Usage
The gform_calculation_formula filter has both a JavaScript version and a PHP version. Both versions should be used.
The JavaScript version only overrides the calculation formula on the front-end.
12345gform.addFilter( 'gform_calculation_formula', function( formula, formulaField, formId, calcObj ) {    // do stuff     return formula;} );
The PHP version overrides the calculation formula when the calculation is rerun during submission using the field values saved in the entry.
12345add_filter( 'gform_calculation_formula', function( $formula, $field, $form, $entry ) {    // do stuff     return $formula;}, 10, 4 );
JavaScript Version

Parameters

formula string
The calculation formula.

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.

calcObj Javascript Object
The calculation object.

JS Example
123456gform.addFilter( 'gform_calculation_formula', function( formula, formulaField, formId, calcObj ) {    if ( formId == '10' && formulaField.field_id == '3' ) {        formula += '+5';    }    return formula;} );
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

$formula string
The calculation formula.

$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.

PHP Example
12345678add_filter( 'gform_calculation_formula', 'change_formula', 10, 4 );function change_formula( $formula, $field, $form, $entry ) {    if ( $form['id'] == 10 && $field->id == 3 ) {        $formula .= '+5';    }     return $formula;}
Placement
This code 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_before_delete_form

gform_before_delete_form

DescriptionUsageParametersExamplesSource Code

Description
Use this action hook to perform actions right before a form is deleted.
Usage
add_action( 'gform_before_delete_form', 'do_cleanup' );

Parameters

$form_id integer
ID of current form.

Examples
This example adds a log file entry when a form is deleted.
add_action( 'gform_before_delete_form', 'log_form_deleted' );
function log_form_deleted( $form_id ) {
$log_file = ABSPATH . '/gf_deleted_forms.log';
$f = fopen( $log_file, 'a' );
$user = wp_get_current_user();

$entry_count = RGFormsModel::get_lead_count( $form_id, '' );

fwrite( $f, date( 'c' ) . " - Form deleted by {$user->user_login}. Form ID: {$form_id}. Entries: {$entry_count} n");
fclose( $f );
}

Source Code
This action hook is located in GFFormsModel::delete_form() in form_model.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_calculation_result

gform_calculation_result

DescriptionUsageJavaScript VersionParametersExamplePlacementSource CodePHP VersionParametersExamplePlacementSource Code

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

Parameters

result float
The calculation result.

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.

calcObj Javascript Object
The calculation object.

Example
This example shows how you can perform a calculation using exponents.
12345678gform.addFilter('gform_calculation_result', function( result, formulaField, formId, calcObj ) {    if ( formId == '10' && formulaField.field_id == '3' ) {        var exponent = calcObj.replaceFieldTags( formId, '{:2}', formulaField ),            num = calcObj.replaceFieldTags( formId, '{:1}', formulaField );        result = Math.pow( num, exponent );    }    return result;} );
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

$result float
The calculation result.

$formula string
The formula after merge tags have been processed.

$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 perform a calculation using exponents.
123456789add_filter( 'gform_calculation_result', function ( $result, $formula, $field, $form, $entry ) {    if ( $form['id'] == 10 && $field['id'] == 3 ) {        $exponent = (float) rgar( $entry, '2' );        $num      = (float) rgar( $entry, '1' );        $result   = pow( $num, $exponent );    }     return $result;}, 10, 5 );
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