Using Gravity Forms ‘gform_web_api_retrieve_form_totals’ PHP filter

The gform_web_api_retrieve_form_totals filter allows you to exclude the entries property (entry totals) from the GET /forms (REST API v1) response. This can help improve performance when entry totals are not needed.

Usage

To use the filter:

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

More information

See Gravity Forms Docs: gform_web_api_retrieve_form_totals

This filter was added in Gravity Forms v2.4.24.1. The source code is located in GFWebAPI::get_forms() in includes/webapi/webapi.php.

Examples

Exclude Entry Totals

Exclude entry totals for all forms:

add_filter('gform_web_api_retrieve_form_totals', '__return_false');

Exclude Entry Totals for Specific Forms

Exclude entry totals for forms with IDs 1, 3, and 5:

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