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_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_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_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_transaction_pre_capture_setup_fee

gform_authorizenet_transaction_pre_capture_setup_fee

DescriptionUsageParametersExamples1. Modify the AmountPlacementSource Code

Description
This filter can be used to modify the transaction object for the subscription setup fee before it is sent to Authorize.net.
Usage
The filter which would run for all 『subscription』 type Authorize.net feeds with a setup fee can be used like so:
add_filter( 'gform_authorizenet_transaction_pre_capture_setup_fee', '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. Modify the Amount
The following example shows how you can override the setup fee for a specific form.
add_filter( 'gform_authorizenet_transaction_pre_capture_setup_fee', 'set_fee_amount', 10, 4 );
function set_fee_amount( $transaction, $form_data, $config, $form ) {
if ( $form['id'] == 10 ) {
$transaction->amount = 50;
}

return $transaction;
}

Placement
Your code snippet should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFAuthorizeNet::subscribe() in class-gf-authorizenet.php

gform_authorizenet_transaction_pre_authorize

gform_authorizenet_transaction_pre_authorize

DescriptionUsageParametersExamplesPlacementSource Code

Description
Allows the transaction to be modified before authorization occurs.
Usage
add_filter( 'gform_authorizenet_transaction_pre_authorize', 'your_function_name', 10, 4 );

Parameters

$original_transaction AuthorizeNetAIM Object
The payment transaction.

$form_data array
Form information needed for billing.

$config array
Configuration information including feed setup with billing information.

$form Form Object
The current form object.

Examples
add_filter( 'gform_authorizenet_transaction_pre_authorize', 'change_authorization', 10, 4 );
function change_authorization( $original_transaction, $form_data, $config, $form ){
return $original_transaction;
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFAuthorizeNet::authorize() in gravityformsauthorizenet/class-gf-authorizenet.php.

gform_authorizenet_subscription_pre_create

gform_authorizenet_subscription_pre_create

DescriptionUsageParametersExamples1. Change startDate2. Change Trial Period Cycles3. Add a Description4. Set the invoice number4. Use Name field for subscription detailsPlacementSource Code

Description

This filter can be used to modify the subscription object before it is sent to Authorize.net.

Usage

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

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

Parameters

$subscription object
The Authorize.net subscription 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. Change startDate

The following example shows how you can set the start date. Please note Authorize.net requires the startDate be in the YYYY-MM-DD format.

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

$subscription->startDate = rgar( $entry, '10' );

return $subscription;
}, 10, 5 );

2. Change Trial Period Cycles

The following example shows how you can set the Trial Period Cycles. Please check the following doc page from Authorize.net to understand how they handle Trial periods: What is a Trial Period?

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

$subscription->trialOccurrences = 15; // This will set a 15 days trial period if Billing Cycle is using Days
return $subscription;
}, 10, 5 );

3. Add a Description

The following example shows how you can set a description (up to 255 characters) for the subscription being created in a form with id 30. According to Authorize.net API documentation the description will be associated with each payment in the subscription.

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

$subscription->orderDescription = 'This is my custom description...';
return $subscription;
}, 10, 5 );

4. Set the invoice number

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

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

GFCommon::log_debug( __METHOD__ . '(): Setting custom invoice number.' );

// Update 46 to the id number of the field containing your invoice number
$subscription->orderInvoiceNumber = rgar( $entry, '46' );
return $subscription;
}, 10, 5 );

4. Use Name field for subscription details

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

add_filter( 'gform_authorizenet_subscription_pre_create', function ( $subscription, $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 $subscription;
}

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

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