rcp_member_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/

This filter was deprecated in version 3.0 Use rcp_membership_is_expired or rcp_user_has_expired_membership instead.

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 );
Powered by Zendesk