RCP_Member

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:
https://codeable.io/developers/restrict-content-pro/

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.

Member Status

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.

For example:

$member = new RCP_Member( 1 );
$status = $member->get_status();

And

$member = new RCP_Member( 1 );
$member->set_status( 'active' );

Expiration Dates

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();

Join Date

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.

  • get_payment_profile_id()

  • set_payment_profile_id( $profile_id = '' )

  • get_subscription_id()

  • set_subscription_id( $subscription_id )

  • get_subscription_key()

  • get_subscription_name()

  • get_payments()

  • get_notes()

  • add_note( $note = '' )

  • is_active()

  • is_recurring()

  • set_recurring( $yes = true )

  • is_expired()

  • is_trialing()

  • has_trialed()

  • can_access( $post_id = 0 )

  • get_switch_to_url()

  • get_prorate_credit_amount()

  • just_upgraded()

Have more questions? Submit a request