Skip to content

Instantly share code, notes, and snippets.

@supercleanse
Created September 27, 2018 18:52
Show Gist options
  • Save supercleanse/06071d806ff86d42ec1fc8e84e973d89 to your computer and use it in GitHub Desktop.
Save supercleanse/06071d806ff86d42ec1fc8e84e973d89 to your computer and use it in GitHub Desktop.
Find Latest Expired Transaction in MemberPress
<?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