rcp_member_is_expired

Filters whether or not a user's membership has expired.

Parameters:

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

Example:

This example modifies the is_expired() method to compare the user's 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, $user_id, $member ) {

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

    $expiration = $member->get_expiration_date( false, 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_member_is_expired', 'ag_rcp_is_expired', 10, 3 );