Created
September 27, 2018 18:52
-
-
Save supercleanse/06071d806ff86d42ec1fc8e84e973d89 to your computer and use it in GitHub Desktop.
Find Latest Expired Transaction in MemberPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_expired_subscription_urls_for_current_user() { | |
$expired_subscription_urls = array(); | |
if(MeprUtils::is_user_logged_in()) { | |
$current_user = MeprUtils::get_currentuserinfo(); | |
$all_subscriptions = $current_user->active_product_subscriptions('transactions', true, false); | |
if(!empty($all_subscriptions)) { | |
foreach($all_subscriptions as $txn) { | |
if($txn->is_expired()) { | |
$membership = $txn->product(); | |
$expired_subscription_urls[] = $membership->url(); | |
} | |
} | |
} | |
} | |
return array_unique($expired_subscription_urls); | |
} | |
$s = get_expired_subscription_urls_for_current_user(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment