rcp_membership_is_expired

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