gform_zapier_request_body

gform_zapier_request_body

DescriptionUsageParametersExamples1. Change Date format2. Send Score for Survey fieldsPlacementSinceSource Code

Description

Allows the request body sent to Zapier to be filtered.

Usage

The following would apply to all forms:

add_filter('gform_zapier_request_body', 'your_function_name', 10, 4);

To target a specific form, append the form id to the hook name.Format: gform_zapier_request_body_FORMID

add_filter('gform_zapier_request_body_1', 'your_function_name', 10, 4);

Parameters

NameTypeNote$bodyarrayAn associative array containing the request body that will be sent to Zapier.$feedFeed ObjectThe feed object currently being processed.$entryEntry ObjectThe entry object currently being processed.$formForm ObjectThe form object currently being processed.

Examples

1. Change Date format

add_filter('gform_zapier_request_body', 'change_date_format', 10, 4);
function change_date_format( $body, $feed, $entry, $form ){
$body['Entry Date'] = gmdate('Y-m-d', strtotime( $entry['date_created'] ) );
return $body;
}

2. Send Score for Survey fields

add_filter( 'gform_zapier_request_body', 'zapier_single_score_export', 10, 4 );
function zapier_single_score_export( $body, $feed, $entry, $form ) {
$survey_fields = GFAPI::get_fields_by_type( $form, array( 'survey' ) );
foreach ( $survey_fields as $field ) {
$body_key = GFZapier::get_body_key( $body, 'Survey Score: ' . $field->label );
$body[ $body_key ] = gf_survey()->get_field_score( $field, $entry );
}

return $body;
}

Placement

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

Since

This filter was added in the Gravity Forms Zapier Add-On v3.1.1.

Source Code

This filter is located in GFZapier::get_body() method in zapier.php.

發表回覆

您的郵箱地址不會被公開。 必填項已用 * 標註