gform_authorizenet_transaction_pre_capture

gform_authorizenet_transaction_pre_capture

DescriptionUsageParametersExamples1. Prevent capture2. Add a custom field3. Set the taxExempt property.4. Set the invoice_num property.5. Add a Description6. Set the shipping address properties7. Set the Customer IP Address as a custom field8. Use Name field for transaction detailsPlacementSource Code

Description

This filter can be used to modify the transaction object before it is sent to Authorize.net. It can also be used to prevent capture by returning false.

Usage

The filter which would run for all 『product and services』 type Authorize.net feeds can be used like so:

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

Parameters

$transaction object
The Authorize.net transaction object.

$form_data Form Data
An associative array containing the form title, billing address, payment amount, setup fee amount, line items created using the submitted pricing field values and any discounts from coupons.

$config Authorize Net Config
The feed which is currently being processed.

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

$entry Entry Object
The entry which is currently being processed. Since version 2.1.8.

Examples

1. Prevent capture

The following example shows how you can prevent the payment being captured.

add_filter( 'gform_authorizenet_transaction_pre_capture', '__return_false' );

2. Add a custom field

The following example shows how you can add a custom Authorize.net field to the transaction and pass it the value from a form field.

add_filter( 'gform_authorizenet_transaction_pre_capture', 'add_custom_field', 10, 5 );
function add_custom_field( $transaction, $form_data, $config, $form, $entry ) {
if ( $form['id'] == 10 ) {
$value = rgpost( 'input_5');
$transaction->setCustomField( 'your_field_name', $value );
}

return $transaction;
}

3. Set the taxExempt property.

The following example shows how you can add a custom Authorize.net field to the transaction and pass it the value from a form field.

add_filter( 'gform_authorizenet_transaction_pre_capture', 'set_tax_exempt', 10, 5 );
function set_tax_exempt( $transaction, $form_data, $config, $form, $entry ) {
if ( $form['id'] == 10 ) {
$transaction->tax_exempt = 'true';
}

return $transaction;
}

4. Set the invoice_num property.

This example shows how to pass an entry value as the transactions invoice number.

add_filter( 'gform_authorizenet_transaction_pre_capture', function( $transaction, $form_data, $config, $form, $entry ) {
if ( $form['id'] == 10 ) {
$transaction->invoice_num = rgar( $entry, '4' );
}

return $transaction;
}, 10, 5 );

5. Add a Description

This example shows how to add a description (up to 255 characters) for one time transactions in a form with id 30.

add_filter( 'gform_authorizenet_transaction_pre_capture', function( $transaction, $form_data, $config, $form, $entry ) {
if ( $form['id'] != 30 ) { // Update 30 to your form id number
return $transaction;
}

$transaction->description = 'This is my custom description...';

return $transaction;
}, 10, 5 );

6. Set the shipping address properties

This example shows how to pass entry values to the transaction shipping address properties.

add_filter( 'gform_authorizenet_transaction_pre_capture', function( $transaction, $form_data, $config, $form, $entry ) {
if ( $form['id'] == 10 ) {
$transaction->ship_to_first_name = rgar( $entry, '1.3' );
$transaction->ship_to_last_name = rgar( $entry, '1.6' );
$transaction->ship_to_company = rgar( $entry, '2' );
$transaction->ship_to_address = rgar( $entry, '3.1' );
$transaction->ship_to_city = rgar( $entry, '3.3' );
$transaction->ship_to_state = rgar( $entry, '3.4' );
$transaction->ship_to_zip_code = rgar( $entry, '3.5' );
$transaction->ship_to_country = rgar( $entry, '3.6' );
}

return $transaction;
}, 10, 5 );

7. Set the Customer IP Address as a custom field

The current version of the add-on doesn』t support using the customerIP property. This example shows a workaround passing the Customer IP address using a custom field.

add_filter( 'gform_authorizenet_transaction_pre_capture', function( $transaction, $form_data, $config, $form, $entry ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );

$transaction->setCustomField( 'Customer IP', rgar( $entry, 'ip' ) );

GFCommon::log_debug( __METHOD__ . '(): Customer IP set to: ' . rgar( $entry, 'ip' ) );

return $transaction;
}, 10, 5 );

8. Use Name field for transaction details

This example shows how to use a Name field as source for Authorize.net』s transaction details.

add_filter( 'gform_authorizenet_transaction_pre_capture', function ( $transaction, $form_data, $config, $form, $entry ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );

if ( $form['id'] != 1 ) { // Update 1 to your form id number
GFCommon::log_debug( __METHOD__ . '(): Not our desired form, leaving without changes.' );
return $transaction;
}

// Set values for transaction First Name and Last Name from a name field with ID 1.
$transaction->first_name = rgar( $entry, '1.3' );
GFCommon::log_debug( __METHOD__ . '(): First Name: ' . $transaction->first_name );
$transaction->last_name = rgar( $entry, '1.6' );
GFCommon::log_debug( __METHOD__ . '(): Last Name: ' . $transaction->last_name );

return $transaction;
}, 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 GFAuthorizeNet::authorize() in class-gf-authorizenet.php.

gform_authorizenet_validation_message

gform_authorizenet_validation_message

DescriptionUsageParametersExamples1. Use the Authorize.net Response Reason TextPlacementSource Code

Description
This filter can be used to modify the validation message added to the credit card field when Authorize.net returns an error during card authorization.
Usage
The filter which would run for all Authorize.net feeds can be used like so:
1add_filter( 'gform_authorizenet_validation_message', 'your_function_name', 10, 5 );

Parameters

$message string
The default error message.

$validation_result array
An associative array containing the form validation result, the form object, and the number of the page where the validation error occurred.

$post array
The global $_POST containing the input values posted by the browser.

$response object
The response from Authorize.net.

$responsetype string
The type of response. Possible values: arb or aim.

Examples
1. Use the Authorize.net Response Reason Text
12345add_filter( 'gform_authorizenet_validation_message', function( $message, $validation_result, $post, $response, $responsetype ) {    $message = $response->response_reason_text;     return $message;}, 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 GFAuthorizeNet::authorize() and GFAuthorizeNet::subscribe() in class-gf-authorizenet.php

GFORM_AUTO_DB_MIGRATION_DISABLED

GFORM_AUTO_DB_MIGRATION_DISABLED

DescriptionUsagePlacement

Description
If the database schema has been updated, setting this constant to true will prevent entries from being migrated in the background.
Usage
1define( 'GFORM_AUTO_DB_MIGRATION_DISABLED', true );
Placement
This constant should be set in your wp-config.php. See the article Wp Config Options for more details.

gform_autoresponder_email

gform_autoresponder_email

DescriptionUsageParametersExamplesSource Code

Description
This filter is executed before sending the user notification email. It can be used to route the notification to a different email address.

This hook has been deprecated in v.1.7. Please use gform_notification instead.

Usage
Applies to all forms
1add_filter( 'gform_autoresponder_email', 'change_notification_email', 10, 2 );
Applies to a specific form. In this case, form Id 5
1add_filter( 'gform_autoresponder_email_5', 'change_notification_email', 10, 2 );

Parameters

$email string
The email address to be filtered.

$form Form Object
The current form.

Examples
This example uses the gform_autoresponder_email filter to send the user notification to a test email address
12345678910add_filter( 'gform_autoresponder_email', 'change_notification_email', 10, 2 );function change_notification_email( $email, $form ) {     //applying notification routing to form Id 2    if ( $form['id'] != 2 )        return $email;     //creating email list from fields 2 and 3.    return $_POST['input_2'] . ',' . $_POST['input_3'];}
Source Code
This filter is located in GFCommon::prepare_user_notification() in form_display.php

gform_aweber_ad_tracking

gform_aweber_ad_tracking

DescriptionUsageParametersExamplePlacementSource Code

Description
This filter can be used to modify the ad_tracking parameter value before it is sent to AWeber.
Usage
The filter which would run for all AWeber feeds can be used like so:
add_filter( 'gform_aweber_ad_tracking', 'your_function_name', 10, 4 );

You can limit the scope of the filter to a single form by appending the form id on the end of the hook name like so:
add_filter( 'gform_aweber_ad_tracking_5', 'your_function_name', 10, 4 );

Parameters

$ad_tracking string
The default value of the ad_tracking parameter is the form title.

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

Example
The following example shows how you can change the parameter value.
add_filter( 'gform_aweber_ad_tracking', function ( $ad_tracking, $form, $entry, $feed ) {

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

Placement
Your code snippet should be placed in the functions.php file of your active theme.
Source Code
apply_filters( "gform_aweber_ad_tracking_{$form['id']}", apply_filters( 'gform_aweber_ad_tracking', $form['title'], $entry, $form, $feed ), $entry, $form, $feed )

This filter is located in GFAWeber::export_feed() in class-gf-aweber.php.

gform_aweber_args_pre_subscribe

gform_aweber_args_pre_subscribe

DescriptionUsageParametersExamples1. Add ip_address ParameterPlacementSource Code

Description
This filter can be used to modify the subscription parameters (arguments) before they are sent to AWeber.
Usage
The filter which would run for all AWeber feeds can be used like so:
add_filter( 'gform_aweber_args_pre_subscribe', 'your_function_name', 10, 4 );

You can limit the scope of the filter to a single form by appending the form id on the end of the hook name like so:
add_filter( 'gform_aweber_args_pre_subscribe_5', 'your_function_name', 10, 4 );

Parameters

$args array
An associative array containing all the parameters to be passed to AWeber.

$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. Add ip_address Parameter
The following example shows how you can add the ip_address parameter.
add_filter( 'gform_aweber_args_pre_subscribe', function ( $args, $form, $entry, $feed ) {
$args['ip_address'] = rgar( $entry, 'ip' );

return $args;
}, 10, 4 );

Placement
Your code snippet should be placed in the functions.php file of your active theme.
Source Code
apply_filters( "gform_aweber_args_pre_subscribe_{$form['id']}", apply_filters( 'gform_aweber_args_pre_subscribe', $params, $form, $entry, $feed ), $form, $entry, $feed )

This filter is located in GFAWeber::export_feed() in class-gf-aweber.php.

gform_aweber_field_value

gform_aweber_field_value

DescriptionUsageParametersExamples1. Change Signature ValuePlacementSource CodeSince

Description
This filter can be used to modify a value before it is sent to AWeber.
Usage
The base filter which would run for all forms and all fields would be used like so:
add_filter( 'gform_aweber_field_value', 'your_function_name', 10, 4 );

To target a specific form append the form id to the hook name. (format: gform_aweber_field_value_FORMID)
add_filter( 'gform_aweber_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_aweber_field_value_FORMID_FIELDID)
add_filter( 'gform_aweber_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.

Examples
1. Change Signature Value
This example shows how you can send the url of the signature image.
add_filter( 'gform_aweber_field_value', 'change_signature_value', 10, 4 );
function change_signature_value( $value, $form_id, $field_id, $entry ) {
$form = GFAPI::get_form( $form_id );
$field = GFFormsModel::get_field( $form, $field_id );

if ( is_object( $field ) && $field->get_input_type() == 'signature' ) {
$value = RGFormsModel::get_upload_url_root() . 'signatures/' . $value;
}

return $value;
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
gf_apply_filters( 'gform_aweber_field_value', array( $form['id'], $field_id ), $field_value, $form['id'], $field_id, $entry )

This filter is located in GFAWeber::maybe_override_field_value() in class-gf-aweber.php.
Since
The base filter was added in version 2.0. The form and field specific versions of this filter were added in version 2.3.

gform_address_street

gform_address_street

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the address street field and can be used to modify the 「Street」 label.
Usage
Applies to all forms.
add_filter( 'gform_address_street', 'change_address_street', 10, 2 );

Applies to a specific form. In this case, form id 5.
add_filter( 'gform_address_street_5', 'change_address_street', 10, 2 );

Parameters

$label string
The label to be filtered.

$form_id integer
The current form』s id.

Examples
This example changes the default address street label:
add_filter( 'gform_address_street', 'change_address_street', 10, 2 );
function change_address_street( $label, $form_id ) {
return "Address Street";
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in js.php and GF_Field_Address::get_field_input() in includes/fields/class-gf-field-address.php.

gform_address_street2

gform_address_street2

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the address street 2 field and can be used to modify the 「Street 2」 label.
Usage
Applies to all forms.
1add_filter( 'gform_address_street2', 'change_address_street2', 10, 2 );
Applies to a specific form. In this case, form id 5.
1add_filter( 'gform_address_street2_5', 'change_address_street2', 10, 2 );
Parameters

$label string
The label to be filtered.

$form_id integer
The current form』s id.

Examples
This example changes the default address street 2 label:
1234add_filter( 'gform_address_street2', 'change_address_street2', 10, 2 );function change_address_street2( $label, $form_id ) {    return "Address Street 2";}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in js.php and GF_Field_Address::get_field_input() in includes/fields/class-gf-field-address.php.

gform_address_types

gform_address_types

DescriptionUsageParametersExamples1. Brasil2. Australia3. United KingdomPlacementSinceSource Code

Description
This filter is executed when creating the address field (admin and front end). Use it to add support for a new address type.
Usage
The following would apply to all forms:
1add_filter( 'gform_address_types', 'brazilian_address', 10, 2 );
To target a specific form, append the form id to the hook name. (format: gform_address_types_FORMID)
1add_filter( 'gform_address_types_5', 'brazilian_address', 10, 2 );

Parameters

$address_types array
A list of all configured address types to be filtered. Following is the default declaration of this array.
123456789101112131415161718192021$addressTypes = array(        'international' => array(            'label'       => 'International',            'zip_label'   => 'Zip / Postal Code',            'state_label' => 'State/Province/Region'        ),        'us'            => array(            'label'       => 'United States',            'zip_label'   => 'Zip Code',            'state_label' => 'State',            'country'     => 'United States',            'states'      => GF_Fields::get( 'address' )->get_us_states(),        ),        'canadian'      => array(            'label'       => 'Canadian',            'zip_label'   => 'Postal Code',            'state_label' => 'Province',            'country'     => 'Canada',            'states'      => GF_Fields::get( 'address' )->get_canadian_provinces()        )    );

$form_id integer
The current form ID.

Examples
1. Brasil
This example adds a Brazilian address type to the list.
123456789101112131415add_filter( 'gform_address_types', 'brazilian_address', 10, 2 );function brazilian_address( $address_types, $form_id ) {    $address_types['brazil'] = array(        'label'       => 'Brasil',        'country'     => 'Brasil',        'zip_label'   => 'CEP',        'state_label' => 'Estado',        'states'      => array(            '', 'Acre', 'Alagoas', 'Amapa', 'Amazonas', 'Bahia', 'Ceara', 'Distrito Federal', 'Espirito Santo', 'Goias', 'Maranhao', 'Mato Grosso', 'Mato Grosso do Sul', 'Minas Gerais',            'Para', 'Paraiba', 'Parana', 'Pernambuco', 'Piaui', 'Roraima', 'Rondonia', 'Rio de Janeiro', 'Rio Grande do Norte', 'Rio Grande do Sul', 'Santa Catarina', 'Sao Paulo', 'Sergipe', 'Tocantins'        )    );     return $address_types;}
2. Australia
This example adds an Australian address type.
123456789101112131415161718192021add_filter( 'gform_address_types', 'australian_address_type' );function australian_address_type( $address_types ) {    $address_types['australia'] = array(        'label'       => 'Australian',        'country'     => 'Australia',        'zip_label'   => 'Postcode',        'state_label' => 'State',        'states'      => array(            'ACT' => 'Australian Capital Territory',            'NT'  => 'Northern Territory',            'NSW' => 'New South Wales',            'QLD' => 'Queensland',            'SA'  => 'South Australia',            'TAS' => 'Tasmania',            'VIC' => 'Victoria',            'WA'  => 'Western Australia',        )    );     return $address_types;}
3. United Kingdom
This example uses optgroups for the counties, a feature added in Gravity Forms 2.0-beta-2.2.
1234567891011121314151617181920212223242526add_filter( 'gform_address_types', 'uk_address', 10, 2 );function uk_address( $address_types, $form_id ) {    $address_types['uk'] = array(        'label'       => 'UK',        'country'     => 'United Kingdom',        'zip_label'   => 'Postcode',        'state_label' => 'County',        'states'      => array(            '',            'England'          => array(                'Avon', 'Bedfordshire', 'Berkshire', 'Buckinghamshire', 'Cambridgeshire', 'Cheshire', 'Cleveland', 'Cornwall', 'Cumbria', 'Derbyshire', 'Devon', 'Dorset', 'Durham', 'East Sussex', 'Essex', 'Gloucestershire', 'Hampshire', 'Herefordshire', 'Hertfordshire', 'Isle of Wight', 'Kent', 'Lancashire', 'Leicestershire', 'Lincolnshire', 'London', 'Merseyside', 'Middlesex', 'Norfolk', 'Northamptonshire', 'Northumberland', 'North Humberside', 'North Yorkshire', 'Nottinghamshire', 'Oxfordshire', 'Rutland', 'Shropshire', 'Somerset', 'South Humberside', 'South Yorkshire', 'Staffordshire', 'Suffolk', 'Surrey', 'Tyne and Wear', 'Warwickshire', 'West Midlands', 'West Sussex', 'West Yorkshire', 'Wiltshire', 'Worcestershire',            ),            'Wales'            => array(                'Clwyd', 'Dyfed', 'Gwent', 'Gwynedd', 'Mid Glamorgan', 'Powys', 'South Glamorgan', 'West Glamorgan',            ),            'Scotland'         => array(                'Aberdeenshire', 'Angus', 'Argyll', 'Ayrshire', 'Banffshire', 'Berwickshire', 'Bute', 'Caithness', 'Clackmannanshire', 'Dumfriesshire', 'Dunbartonshire', 'East Lothian', 'Fife', 'Inverness-shire', 'Kincardineshire', 'Kinross-shire', 'Kirkcudbrightshire', 'Lanarkshire', 'Midlothian', 'Moray', 'Nairnshire', 'Orkney', 'Peeblesshire', 'Perthshire', 'Renfrewshire', 'Ross-shire', 'Roxburghshire', 'Selkirkshire', 'Shetland', 'Stirlingshire', 'Sutherland', 'West Lothian', 'Wigtownshire',            ),            'Northern Ireland' => array(                'Antrim', 'Armagh', 'Down', 'Fermanagh', 'Londonderry', 'Tyrone',            ),        ),    );     return $address_types;}
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms version 1.4.
Source Code
This action hook is located in GF_Field_Address::get_address_types() in includes/fields/class-gf-field-address.php.