Forked from andrija-naglic/mepr-active-memberships.php
Created
March 11, 2020 08:39
-
-
Save himanshuahuja96/98bd15068342e3e958c7f73a7c1063ee 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 | |
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