gform_square_show_custom_app_settings

gform_square_show_custom_app_settings

DescriptionUsageParametersExamplesPlacementInput for Custom App Settings for SquareSinceSource Code

Description
The gform_square_show_custom_app_settings filter allows displaying the custom app settings link in the Square add-on settings page.
Usage
add_filter( 'gform_square_show_custom_app_settings', 'your_function_name', 10, 1 );

Parameters

$show_settings bool
Defaults to false, return true to show custom app settings.

Examples
add_filter( 'gform_square_show_custom_app_settings', '__return_true' );

Placement
Your code snippet should be placed in the functions.php file of your active theme.
Input for Custom App Settings for Square
After you』ve added the filter above, you will have a new option in the Form > Settings > Square Settings screen:

You will have a new link underneath the regular Mode selection for Square to 「I want to use a custom app」. Selecting this link will present you with a new screen to input your Custom Application authentication:

In addition to the regular Mode Settings for Square (Live and Sandbox), the following three fields are available:

OAuth Redirect URI: This will change depending on whether you are pointing to Live or Sandbox, but the URI is not editable.
App ID: This input will be provided by the Custom Application settings in Square and you can copy and paste them from the Square configuration.
App Secret: This will also be provided by the Custom Application settings in Square.

If you no longer wish to use a Custom App Settings, click the link for 「I do not want to use a custom app」.
Since
This filter was added in Square version 1.0.
Source Code
$show_settings = apply_filters( 'gform_square_show_custom_app_settings', false );

This hook is located in GF_Square::show_custom_app_settings() in class-gf-square.php.

gform_square_payment_data

gform_square_payment_data

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description

Use this filter to modify the payment data before it is sent to Square.

Usage

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

Parameters

$payment_data array
An array that contains payment properties and their values as documented in https://developer.squareup.com/reference/square/payments-api/create-payment

$feed array
The feed object currently being processed.

$submission_data array
The customer and transaction data.

$form Form Object
The form object currently being processed.

$entry Entry Object
The entry object currently being processed.

Examples

Pass a custom note to Square in the payment data.

add_filter( 'gform_square_payment_data', 'change_payment_data', 10, 5 );
function change_payment_data( $payment_data, $feed, $submission_data, $form, $entry ) {
$payment_data['note'] = 'Custom note';
return $payment_data;
}

Placement

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

Since

This filter was added in Square version 1.0.

Source Code

This filter is located in GF_Square::authorize_product() in gravityformssquare/class-gf-square.php.

gform_square_data_sync_enabled

gform_square_data_sync_enabled

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description

Allows the syncing of subscription data between your Square account and your website data.

Usage

1add_filter( 'gform_square_data_sync_enabled', 'your_function_name' );

Parameters

$enabled bool
If data sync should occur. Default is enabled.

Examples

Disables data sync for Square.

12345add_filter( 'gform_square_data_sync_enabled', 'disable_square_data_sync' );function disable_square_data_sync( $enabled ) {    $enabled = false; // disable sync    return $enabled;}

Placement

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

Since

This filter was added in Square version 1.4.

Source Code

This filter is located in GF_Square::is_sync_enabled() in gravityformssquare/class-gf-square.php.

gform_square_card_style

gform_square_card_style

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
This filter allows you to pass CSS-like properties and values to Square to control the look of the Square field.
For more information about which styles may be applied, check out the style reference in Square』s documentation.
Usage
1add_filter( 'gform_square_card_style', 'your_function_name', 10, 2 );

Parameters

$default_styles array
Array that contains css properties and their values, property names and values should match inputStyle documentation here.

$form_id int
The current form id.

Examples
Changes the card details field background to black and text color to white.
123456add_filter( 'gform_square_card_style', 'change_style', 10, 2 );function change_style( $default_styles, $form_id ) {    $default_styles['backgroundColor'] = '#000000';    $default_styles['color'] = '#ffffff';    return $default_styles;}
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Square version 1.0.
Source Code
This filter is located in GF_Square::register_init_scripts() in gravityformssquare/class-gf-stripe.php.

gform_square_authorization_only

gform_square_authorization_only

DescriptionUsageParametersExamples1. Apply to all product and service feeds2. Apply to a specific feedPlacementSinceSource Code

Description
The gform_square_authorization_only filter allows authorization only transactions by preventing the capture request from being made after the entry has been saved.
Note: Payments that are only authorized and not captured via your Square dashboard within 6 days will automatically expire.
Usage
The hook which would run for all Square product and service feeds can be used like so:
1add_filter( 'gform_square_authorization_only', 'your_function_name', 10, 5 );

Parameters

$authorization_only bool
Defaults to false, return true to prevent payment being captured.

$feed Feed Object
The feed object currently being processed.

$submission_data Submission Data
The customer and transaction data.

$form Form Object
The form object currently being processed.

$entry Entry Object
The entry object currently being processed.

Examples
1. Apply to all product and service feeds
1add_filter( 'gform_square_authorization_only', '__return_true' );
2. Apply to a specific feed
The following example shows how you can delay the subscription cancellation for a specific feed by checking the feed name.
123456789add_filter( 'gform_square_authorization_only', 'square_authorization_only', 10, 2 );function square_authorization_only( $authorization_only, $feed ) {    $feed_name  = rgars( $feed, 'meta/feedName' );    if ( $feed_name == 'your feed name here' ) {        return true;    }     return $authorization_only;}
Placement
Your code snippet should be placed in the functions.php file of your active theme.
Since
This hook was added in Square version 1.0.
Source Code
1$authorization_only = apply_filters( 'gform_square_authorization_only', false, $feed, $submission_data, $form, $entry );
This hook is located in GF_Square::get_capture_method() in class-gf-square.php.

gform_spinner_url

gform_spinner_url

DescriptionUsageParametersExamplePlacementSinceSource Code

Description
Allows modifying the spinner URL when the gformAddSpinner() function is called directly.
If the spinner URL is not implemented using the gformAddSpinner function, the URL should be changed using the gform_ajax_spinner_url filter.
Usage
gform.addFilter('gform_spinner_url', 'change_spinner');
function change_spinner(){ spinnerUrl, formId )
//do something here
return spinnerUrl;
}

Parameters

spinnerUrl string
The URL to the image used for the spinner.

formId int
The current form ID.

Example
gform.addFilter('gform_spinner_url', 'change_spinner');
function change_spinner(){ spinnerUrl, formId )
spinnerUrl = 'https://your-domain-here.test/wp-content/uploads/spinner.svg';
return spinnerUrl;
}

Placement
This code should be placed in a custom JavaScript file used by your theme.
Since
This filter was added in Gravity Forms version 1.8.
Source Code
This filter is located in gformAddSpinner() in js/gravityforms.js.

gform_spinner_target_elem

gform_spinner_target_elem

DescriptionUsageParametersExamples1. Specify a Custom Target for AJAX SpinnerSource CodeSince

Description
Use this filter to modify the element after which the AJAX spinner will be inserted for AJAX-enabled forms. By default, it will be the next button (for multi-page forms) or submit button.
Usage
123gform.addFilter( 'gform_spinner_target_elem', function( $targetElem, formId ) {    return $( '#my-custom-elem' );} );

Parameters

$targetElem object
jQuery object containing all of the elements after which the AJAX spinner will be inserted.

formId integer
ID of the current form.

Examples
1. Specify a Custom Target for AJAX Spinner
123gform.addFilter( 'gform_spinner_target_elem', function( $targetElem, formId ) {    return $( '#my-custom-footer-elem' );} );
Source Code
This filter is located in gformInitSpinner() in js/gravityforms.js
Since
This filter was added in Gravity Forms 2.0-beta-2.2.

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

gform_{$SHORT_SLUG}_error

gform_{$SHORT_SLUG}_error

DescriptionShort SlugsUsageParametersExamples1. Mailchimp API IssuePlacementSource CodeSince

Description
This action hook can be used to perform a custom action when an Add-On Framework based add-on experiences an error when processing a feed.
Short Slugs
The Gravity Forms Add-On Slugs article lists the short slugs for the available add-ons.
The following add-ons currently use this hook:

Advanced Post Creation
Agile CRM
Aweber
Breeze
Campaign Monitor
Campfire
Capsule CRM
CleverReach
Constant Contact
Dropbox
EmailOctopus
GetResponse
Help Scout
Highrise
HubSpot
iContact
MailChimp
Mailgun
Postmark
Slack
Trello
Twilio
Webhooks
Zoho CRM

Usage
The base hook which would run for all feeds and would be used like so:
1add_action( 'gform_mailchimp_error', 'your_function_name', 10, 4 );
This runs the hook for the Agile CRM add-on:
1add_action( 'gform_agilecrm_error', 'your_function_name', 10, 4 );
To target feeds for a specific form, append the form id to the hook name. (format: gform_{$SHORT_SLUG}_error_FORMID)
1add_action( 'gform_mailchimp_error_10', 'your_function_name', 10, 4 );

Parameters

$feed Feed Object
The feed currently being processed.

$entry Entry Object
The entry currently being processed.

$form Form Object
The form currently being processed.

$error string
The error message.

Examples
1. Mailchimp API Issue
This example shows how you can trigger the sending of a notification if the Mailchimp API could not be initialized. You can adapt this example for use with any other Add-On Framework based add-on replacing mailchimp with any other supported add-on slug.
1234add_action( 'gform_mailchimp_error', 'send_mailchimp_error_email', 10, 4 );function send_mailchimp_error_email( $feed, $entry, $form, $error_message ) {    GFAPI::send_notifications( $form, $entry, 'mailchimp_api_issue' );}
The mailchimp_api_issue notification event would be added via the gform_notification_events filter.
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This hook is located in GFFeedAddOn::add_feed_error() in includes/addon/class-gf-feed-addon.php.
Since
This hook was added in Gravity Forms 1.9.11.9.

gform_slack_username

gform_slack_username

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
This filter is used to dynamically change the username the message is being sent by before it is sent to Slack.
Usage
The following would apply to all forms:
add_filter( 'gform_slack_username', 'your_function_name', 10, 4 );

To target a specific form append the form id to the hook name. (Format: gform_slack_username_FORMID)
add_filter( 'gform_slack_username_10', 'your_function_name', 10, 4 );

Parameters

$username string
The current username being used for the Slack message. Default is: Gravity Forms.

$feed Feed Object
The current feed object.

$entry Entry Object
The current entry object.

$form Form Object
The current form object.

Examples
This example changes the username for a specific form.
add_filter( 'gform_slack_username_4', 'change_slack_username', 10, 4 );
function change_slack_username( $username, $feed, $entry, $form ) {

$username = 'Support Bot';

return $username;

}

Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in version 1.3.
Source Code
gf_apply_filters( 'gform_slack_username', array( $form['id'] ), 'Gravity Forms', $feed, $entry, $form )
This filter is located in GFSlack::process_feed() in class-gf-slack.php.