Restrict Content Pro
rcp_user_has_free_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
Returns whether the customer has at least one free membership whose status slug is active. The function queries memberships with 'status' => 'active' and returns true if any of them are not paid (RCP_Membership::is_paid() is false).
This is not the same as rcp_user_has_active_membership(): a cancelled free membership that is still within its access period may count as active there but not here.
Parameters
$user_id (int) – User ID to check. Default: 0 (current logged-in user).
Return values
(bool) – true if the customer has at least one membership with status active on a free level; false if there is no customer, no active memberships, or every active membership is paid.
Examples
if ( rcp_user_has_free_membership() ) {
// Current user has an active free membership.
}
if ( rcp_user_has_active_membership( $user_id ) && ! rcp_user_has_paid_membership( $user_id ) ) {
// Active member, but not on a paid level.
}
// May be true even when rcp_user_has_free_membership() is false:
if ( rcp_user_has_active_membership( $user_id ) ) {
// User still has access via active or cancelled-not-expired membership.
}