rcp_membership_is_expired

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/

Filters whether or not a membership has expired.

This filter replaced rcp_member_is_expired in version 3.0.

Parameters:

  • $is_expired (bool) - Whether or not the user's membership has expired.
  • $membership_id (int) - ID of the membership being checked.
  • $membership (RCP_Membership) - RCP_Membership object.

Example:

This example modifies the is_expired() method to compare the membership expiration date to two hours ago rather than now (effectively giving the user two extra hours of membership time).

function ag_rcp_is_expired( $is_expired, $membership_id, $membership ) {

    // Exit early if the user hasn't expired yet.
    if ( ! $is_expired ) {
        return $is_expired;
    }

    $expiration = $membership->get_expiration_date( false );

    if( $expiration && strtotime( '-2 hours', current_time( 'timestamp' ) ) > strtotime( $expiration, current_time( 'timestamp' ) ) ) {
        $is_expired = true;
    } else {
        $is_expired = false;
    }

    return $is_expired;

}
add_filter( 'rcp_membership_is_expired', 'ag_rcp_is_expired', 10, 3 );
Have more questions? Submit a request
Powered by Zendesk