Restrict Content Pro
RCP_Member
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
The RCP_Member class was deprecated in version 3.0. Use RCP_Membership and RCP_Customer instead. The notes below are kept for legacy code that still references RCP_Member.
RCP_Member extends WP_User and provides access to member-specific data. It is used mainly when retrieving or updating account details for a member.
Member status
Every member has a status:
free– Has not paid; same as a standard WordPress user account.pending– Transitioning to active; payment is usually pending.active– Account is in good standing.cancelled– Cancelled; access continues until expiration.expired– Expiration date has passed.
Methods
get_status()– Returns the current status.set_status( $new_status )– Sets the status.
Examples
$member = new RCP_Member( 1 );
$status = $member->get_status();
$member = new RCP_Member( 1 );
$member->set_status( 'active' );
Expiration dates
Expiration dates are stored in Y-n-d H:i:s format.
get_expiration_date( $formatted = true )– Human-readable date; passfalsefor unformatted.get_expiration_time()– Unix timestamp.set_expiration_date( $new_date )– New date asY-n-d H:i:s.
$member = new RCP_Member( 1 );
$member->set_expiration_date( '2015-12-01 12:12:01' );
Lifetime (never expire): pass none.
$member = new RCP_Member( 1 );
$member->set_expiration_date( 'none' );
Renew/Cancel
renew() and cancel() activate or deactivate without manually setting status or expiration.
$member = new RCP_Member( 1 );
$member->renew();
Recurring subscription: pass true to renew().
$member = new RCP_Member( 1 );
$member->renew( true );
$member = new RCP_Member( 1 );
$member->cancel();
Cancel recurring billing at the gateway:
$member = new RCP_Member( 1 );
$member->cancel_payment_profile();
Join date
get_joined_date( $subscription_id = 0 ) – Join date in MySQL format. Optional membership level ID; if omitted, uses the current level.
Additional helper methods
Payment gateway and subscription identifiers
- get_payment_profile_id() — Returns the gateway payment profile ID (customer ID or similar) stored for this member. Maps to the membership’s gateway customer ID when a membership exists.
- set_payment_profile_id( $profile_id = ” ) — Sets the gateway payment profile ID on the member’s membership record.
Membership level (RCP subscription level, not the processor)
- get_subscription_id() — Returns the ID of the member’s membership level (
object_id), orfalseif none. - set_subscription_id( $subscription_id ) — Sets the membership level ID on the member’s membership record.
- get_subscription_key() — Returns the unique subscription key for the membership.
- get_subscription_name() — Returns the human-readable name of the member’s current membership level (via
rcp_get_subscription_name()).
Payments and notes
- get_payments() — Returns all payments for the member’s customer record as an array of objects, or
nullif there is no customer. - get_notes() — Returns admin notes stored on the customer record, or
falseif there is no customer. - add_note( $note = ” ) — Appends an admin note on the customer record. Returns
trueon success,falseif there is no customer.
Status and access
- is_active() —
trueif the user can access member content: site administrators always returntrue; otherwise the membership must be active and paid. Filter:rcp_is_active. - is_recurring() —
trueif the membership is set as recurring. - set_recurring( $yes = true ) — Sets whether the membership is recurring.
- is_expired() —
trueif the membership is expired. - is_trialing() —
trueif the membership is in a trial period. - has_trialed() —
trueif the customer has ever used a trial (customer-level check). - can_access( $post_id = 0 ) —
trueif the member may view the given post: administrators and unrestricted posts always pass; restricted posts delegate to the customer’s access rules. Filter:rcp_member_can_access.
Upgrades, proration, and admin tools
- get_switch_to_url() — If the User Switching plugin is active, returns a URL for an admin to switch into this user’s account (with redirect to the home URL). Otherwise returns
false. - get_prorate_credit_amount() — Returns the prorate credit amount for unused time on the current membership when upgrading or changing levels;
0if there is no membership. - just_upgraded() — Returns a Unix timestamp for a recent level upgrade stored in user meta, or
falseif none or if the upgrade was more than about five minutes ago. Filter:rcp_member_just_upgraded.