The RCP_Member class was deprecated in version 3.0. See RCP_Membership and RCP_Customer instead.
Note: This is part of the developer docs and is considered custom code.
Unfortunately, we cannot provide support for custom code at this time as we do not have the additional resources that would be necessary to provide support for custom code.
If you need assistance with this, please reach out to our list of consultants for further assistance:
The RCP_Member class is an extension of WP_User and provides easy access to member-specific data. This class is used primarily when retrieving or updating account details for a member.
Every member has a status attached to their account:
- free - This is a member that has not paid and is the same as a standard WordPress user account.
- pending - This is a member that is transitioning from a free, expired, or cancelled member to an active member. Usually this means their payment is pending.
- active - This is a member whose account is in good standing.
- cancelled - This is a member that has cancelled their account. Cancelled accounts retain access to content until their expiration date is reached.
- expired - This is a member who has reached their expiration date.
There are several methods for interacting with member statuses.
- get_status() - Use this to retrieve the current status of a member.
- set_status( $new_status ) - Use this to set the member's status.
$member = new RCP_Member( 1 ); $status = $member->get_status();
$member = new RCP_Member( 1 ); $member->set_status( 'active' );
Most member accounts have an expiration date assigned to them. Expiration dates are stored in Y-n-d H:i:s formats.
- get_expiration_date( $formatted = true ) - This retrieves the expiration date in a human readable format. Pass false to retrieve a non-formatted version.
- get_expiration_time() - This retrieves the expiration date as a unix timestamp.
- set_expiration_date( $new_date ) - Sets the expiration date to a new date. The date should be provided as Y-n-d H:i:s
$member = new RCP_Member( 1 ); $member->set_expiration_date( '2015-12-01 12:12:01' );
If you wish to set a member so they never expire, pass none as the date.
$member = new RCP_Member( 1 ); $member->set_expiration_date( 'none' );
Renew / Cancel
One of the most helpful aspects of the RCP_Member class is the renew() and cancel() methods that allow you to easily activate or deactivate a member's account without having to worry about manually setting the status or expiration dates.
To renew a member and automatically set the status and expiration date:
$member = RCP_Member( 1 ); $member->renew();
If the member has a recurring subscription, pass true to the renew() method to ensure the recurring status is properly set:
$member = RCP_Member( 1 ); $member->renew( true );
To cancel a member:
$member = RCP_Member( 1 ); $member->cancel();
To cancel a member's recurring payment at the gateway:
$member = RCP_Member( 1 ); $member->cancel_payment_profile();
This can be used to retrieve the date the user joined a subscription level in MySQL format. The method accepts one optional parameter: the ID of the subscription level to get the join date for. If omitted, it gets the date the user joined their current level.
get_joined_date( $subscription_id = 0 )
Additional Helper Methods
There are numerous other helper methods provided by RCP_Member that can be useful when doing custom development around Restrict Content Pro.
set_payment_profile_id( $profile_id = '' )
set_subscription_id( $subscription_id )
add_note( $note = '' )
set_recurring( $yes = true )
can_access( $post_id = 0 )