Restrict Content Pro
rcp_get_membership()
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
Retrieves a single membership record by ID. Returns an RCP_Membership object you can use for status, dates, gateway IDs, and helper methods.
To query multiple memberships, use rcp_get_memberships(). To look up one membership by another column (such as subscription_key), use rcp_get_membership_by( $field, $value ) in code (that helper only returns enabled memberships).
Parameters
$membership_id (int) — ID of the membership row in the database.
Return values
RCP_Membership|false — The membership object, or false if no membership exists for that ID.
Examples
Load a membership and read its status:
$membership = rcp_get_membership( 123 );
if ( $membership ) {
echo $membership->get_status();
}
Get a customer’s memberships via RCP_Customer, then load one by ID:
$customer = rcp_get_customer_by_user_id( 44 );
if ( $customer ) {
foreach ( $customer->get_memberships() as $membership ) {
echo $membership->get_membership_level_name();
}
}