gform_web_api_retrieve_form_totals

gform_web_api_retrieve_form_totals

DescriptionUsageParametersExamples1. Simple Usage2. Advanced UsagePlacementSinceSource Code

Description
The gform_web_api_retrieve_form_totals filter allows the entries property (entry totals) to be omitted from the GET /forms (REST API v1) response. This is useful for increasing performance of the endpoint when totals aren』t required.
Usage
The filter would be used like so:
add_filter( 'gform_web_api_retrieve_form_totals', 'your_function_name', 10, 2 );

You can also specify this per form by adding the form id after the filter name.
add_filter( 'gform_web_api_retrieve_form_totals_6', 'your_function_name', 10, 2 );

Parameters

$include_totals boolean
Whether to include totals; defaults to true.

$form object
The current form properties (id, title, date_created, is_active).

Examples
1. Simple Usage
add_filter( 'gform_web_api_retrieve_form_totals', '__return_false' );

2. Advanced Usage
add_filter( 'gform_web_api_retrieve_form_totals', function ( $include_totals, $form ) {
return ! in_array( $form->id, array( 1, 3, 5 ) );
}, 10, 2 );

Placement
This code should be placed in the functions.php file of your active theme or a custom functions plugin.
Since
This filter was added in Gravity Forms v2.4.24.1.
Source Code
This filter is located in GFWebAPI::get_forms() in includes/webapi/webapi.php.

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注