Skip to content

Instantly share code, notes, and snippets.

@supercleanse
Last active December 18, 2015 17:19
Show Gist options
  • Save supercleanse/5818063 to your computer and use it in GitHub Desktop.
Save supercleanse/5818063 to your computer and use it in GitHub Desktop.
Lifetime access after limit_cycles reached
<?php
add_action( 'mepr-limit-payment-cycles-reached', 'cool_limit_payment_cycles_lifetime' );
function cool_limit_payment_cycles_lifetime( $mepr_subscription = null ) {
if( !is_a( $mepr_subscription, 'MeprSubscription' )
return false;
$txn = $mepr_subscription->latest_txn();
$txn->expires_at = 0; // Zero for lifetime expiration
$txn->store();
}
@brandondove
Copy link

I added a little sanity check at the beginning

<?php

add_action( 'mepr-limit-payment-cycles-reached', 'cool_limit_payment_cycles_lifetime' );
function cool_limit_payment_cycles_lifetime( $mepr_subscription = null ) {

    if( !is_a( $mepr_subscription, 'MeprSubscription' )
        return false;

    $txn = $mepr_subscription->latest_txn();
    $txn->expires_at = 0; // Zero for lifetime expiration
    $txn->store();
}

@supercleanse
Copy link
Author

Great idea ... just updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment