The gform_rest_api_retrieve_form_totals filter allows the entries property (entry totals) to be omitted from the GET /forms (REST API v2) response, which can increase the performance of the endpoint when totals aren’t required.
Usage
add_filter('gform_rest_api_retrieve_form_totals', 'your_function_name', 10, 2);
To specify this per form, add the form ID after the filter name:
add_filter('gform_rest_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).
More information
See Gravity Forms Docs: gform_rest_api_retrieve_form_totals
This filter was added in Gravity Forms v2.4.24.1.
Source code for this filter is located in GF_REST_Forms_Controller::get_items
in includes/webapi/v2/includes/controllers/class-controller-forms.php
.
Examples
Simple Usage
Omit entry totals from the GET /forms response:
add_filter('gform_rest_api_retrieve_form_totals', '__return_false');
Advanced Usage
Omit entry totals for forms with specific IDs (1, 3, and 5) from the GET /forms response:
add_filter('gform_rest_api_retrieve_form_totals', function($include_totals, $form) { return !in_array($form->id, array(1, 3, 5)); }, 10, 2);