Restrict Content Pro

rcp_count_memberships()

Coming soon: Restrict Content Pro is becoming Kadence Memberships. You may see both names used while we update the product, documentation, and customer experience.

Note: This content is provided as a resource within our developer documentation. Because custom code requires highly specific implementation, we encourage you to work with a qualified developer if you need guidance. You can find our recommended consultants here: https://codeable.io/developers/restrict-content-pro

Returns how many memberships match a query. It uses the same arguments as rcp_get_memberships(), with count set to true internally. By default only enabled memberships are counted (disabled => 0).

Parameters

$args (array) – Optional. Same keys as rcp_get_memberships(). Do not pass count yourself; this function sets it. Common filters: status, object_id (membership level ID), customer_id, gateway, expiration_date_query, disabled, number, offset.

Return values

(int) – Number of matching memberships.

Examples

Count active memberships:

$total = rcp_count_memberships( array(
	'status' => 'active',
) );

Count expired memberships on level #3:

$total = rcp_count_memberships( array(
	'object_id' => 3,
	'status'    => 'expired',
) );

Count memberships expiring in December 2024:

$total = rcp_count_memberships( array(
	'expiration_date_query' => array(
		'after'  => date( '2024-12-01 00:00:00', current_time( 'timestamp' ) ),
		'before' => date( '2024-12-31 23:59:59', current_time( 'timestamp' ) ),
	),
) );
Last updated: October 9, 2026
Was this page helpful?
Thanks for the feedback!