Created
March 7, 2018 15:51
-
-
Save cartpauj/be4c2eb63432e8a8942a8fa4cc321f3b to your computer and use it in GitHub Desktop.
Get a list of the current user's active MemberPress Subscriptions
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 | |
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
@cartpauj Thank you!
I was thinking to check for a different way, since mine was make me feel not secure: not sure if the result is ever correct the way of my snippet (if some order change for example). Anyway your seem to me that do not return the same like into mine, that should be something like:
Array ( [11000] => Annual Membership - Auto Renewing [13000] => Monthly Membership – Manually Renewing )
product ID => product Name