Skip to content
Docs
Get RestroPress

Filter

rpress_api_stats_customers

Updated
On this page

Filters the customer statistics returned by the stats API endpoint.

Runs in RPRESS_API::get_stats() when the request type is 'customers'. The array contains 'customers' => 'total_customers', counted either from the legacy payment meta or from the customers table depending on whether the customer upgrade has completed. Use it to add further customer figures.

Parameters#

ParameterTypeDescription
$statsarrayCustomer statistics; $stats['customers']['total_customers'] holds the customer count.
$thisRPRESS_APIThe API instance handling the request.

Return value#

array. The customer statistics to return.

Example#

function my_api_stats_customers( $stats, $api ) {
	$stats['customers']['has_customers'] = ! empty( $stats['customers']['total_customers'] );
	return $stats;
}
add_filter( 'rpress_api_stats_customers', 'my_api_stats_customers', 10, 2 );

Notes#

Fired from two branches of get_stats() with the same arguments.

Source#

Applied in:

  • includes/api/class-rpress-api.php (line 1140), in RPRESS_API::get_stats()
  • includes/api/class-rpress-api.php (line 1144), in RPRESS_API::get_stats()

See also#

Was this page helpful?