Skip to content

Instantly share code, notes, and snippets.

@obiPlabon
Forked from cartpauj/mepr-active-memberships.php
Last active August 29, 2020 06:28
Show Gist options
  • Save obiPlabon/4ac050a86101fa23510a38f80fbd79d2 to your computer and use it in GitHub Desktop.
Save obiPlabon/4ac050a86101fa23510a38f80fbd79d2 to your computer and use it in GitHub Desktop.
Get a list of the current user's active MemberPress Subscriptions
<?php
if(class_exists('MeprUtils')) {
$user = MeprUtils::get_currentuserinfo();
if($user !== false && isset($user->ID)) {
//Returns an array of Membership ID's that the current user is active on
//Can also use 'products' or 'transactions' as the argument type
$active_prodcuts = $user->active_product_subscriptions('ids');
if(!empty($active_prodcuts)) {
foreach($active_prodcuts as $membership_id) {
// Do something
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment