Restrict Content Pro

rcp_get_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

Query for memberships.

Parameters

$args (array) – All optional:

  • $id (int) – Single membership ID.
  • $id__in, $id__not_in (array) – Include or exclude membership IDs.
  • $customer_id (int) – This customer’s memberships only.
  • $customer_id__in, $customer_id__not_in (array) – Customer ID filters.
  • $object_id (int) – Membership level ID.
  • $object_id__in, $object_id__not_in (array) – Level ID filters.
  • $object_type (string) – Object type filter.
  • $object_type__in, $object_type__not_in (array) – Object type filters.
  • $currency (string) – Currency code.
  • $created_date_query, $trial_end_date_query, $cancellation_date_query, $expiration_date_query (array) – See WP_Date_Query.
  • $auto_renew (int) – 1 recurring, 0 not; default null.
  • $status (string) – pending, active, cancelled, expired.
  • $status__in, $status__not_in (array) – Status filters.
  • $gateway_customer_id, $gateway_subscription_id, $gateway, $subscription_key (string).
  • $upgraded_from (int) – Upgraded-from membership ID.
  • $disabled (int|null) – null all, 0 enabled only (default), 1 disabled only.
  • $meta_query (array) – Meta query arrays (array of arrays).
  • $count (bool) – Count vs objects; default false.
  • $fields (string) – Column name or empty for full objects.
  • $number (int) – Limit; default 20.
  • $offset (int) – Offset; default 0 (not 20).
  • $no_found_rows (bool) – Disable SQL_CALC_FOUND_ROWS; default true.
  • $orderby, $order (string) – Sort; default id / DESC.
  • $search (string).
  • $update_cache (bool) – Prime cache; default false.

Return values

(array) – RCP_Membership objects.

Examples

Active memberships:

$memberships = rcp_get_memberships( array(
	'status' => 'active'
) );

Expired on level #3:

$memberships = rcp_get_memberships( array(
	'object_id' => 3,
	'status'    => 'expired'
) );

Five Stripe memberships:

$memberships = rcp_get_memberships( array(
	'number'  => 5,
	'gateway' => 'stripe'
) );

Expire memberships in a December 2024 window:

$memberships = rcp_get_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' ) ),
	),
	'number' => 9999
) );

if ( ! empty( $memberships ) ) {
	foreach ( $memberships as $membership ) {
		$membership->expire();
	}
}

Cancel auto-renew on active memberships:

$memberships = rcp_get_memberships( array(
	'status'     => 'active',
	'auto_renew' => 1,
	'number'     => 9999
) );

if ( ! empty( $memberships ) ) {
	foreach ( $memberships as $membership ) {
		if ( $membership->can_cancel() ) {
			$membership->cancel_payment_profile();
		}
	}
}

Active memberships with meta company = Sandhills:

$memberships = rcp_get_memberships( array(
	'status'     => 'active',
	'number'     => 9999,
	'meta_query' => array(
		array(
			'key'   => 'company',
			'value' => 'Sandhills',
		)
	)
) );
Last updated: October 7, 2026
Was this page helpful?
Thanks for the feedback!