Forked from andrija-naglic/mepr-active-memberships.php
Created
August 29, 2020 06:30
-
-
Save obiPlabon/4fc3240c458e7f2c8613f3e56c8ed36f to your computer and use it in GitHub Desktop.
Get a list of the current user's active MemberPress Subscriptions
This file contains hidden or 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