gform_entries_filter_count_queries

The gform_entries_filter_count_queries filter allows the queries used to get the counts for the entries list filter links to be overridden.

Usage

add_filter( 'gform_entries_filter_count_queries', 'your_function_name', 10, 2 );

Parameters

ParameterTypeDescription
$parameterarrayThe filter count queries.
$form_idintThe ID of the form for which the queries are being prepared.

The default value of $queries:

$queries = array(
	"COUNT(DISTINCT CASE WHEN l.status='active' THEN l.id END) as total",
	"COUNT(DISTINCT CASE WHEN l.is_read=0 AND l.status='active' THEN l.id END) as unread",
	"COUNT(DISTINCT CASE WHEN l.is_starred=1 AND l.status='active' THEN l.id END) as starred",
	"COUNT(DISTINCT CASE WHEN l.status='spam' THEN l.id END) as spam",
	"COUNT(DISTINCT CASE WHEN l.status='trash' THEN l.id END) as trash",
);

Examples

Add Custom Entry Count for Toxic Status.

add_filter( 'gform_entries_filter_count_queries', function ( $queries ) {
    $queries[] = "COUNT(DISTINCT CASE WHEN l.status='toxic' THEN l.id END) as toxic";

    return $queries;
} );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Since

This filter was added in Gravity Forms 2.9.16

Source Code

This filter is located in  GFFormsModel::get_form_counts() in forms_model.php