Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save himanshuahuja96/98bd15068342e3e958c7f73a7c1063ee to your computer and use it in GitHub Desktop.
Save himanshuahuja96/98bd15068342e3e958c7f73a7c1063ee to your computer and use it in GitHub Desktop.
Get a list of the current user's active MemberPress Subscriptions
<?php
function memberpress__get_all_memberships( $user_id = false ){
if( class_exists('MeprUser') ){
if( ! $user_id ){
$user_id = get_current_user_id();
}
$user = new MeprUser( $user_id );
$get_memberships = $user->active_product_subscriptions();
if( !empty( $get_memberships ) ){
$user_memberships = array_values( array_unique( $get_memberships ) );
} else {
$user_memberships = array();
}
return $user_memberships;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment