Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Very basic custom RESTful API to check the membership level of a Paid Memberships Pro User
Call to to check the membership level of a user.
function my_init_pmpro_mini_api()
if(function_exists('pmpro_getMembershipLevelForUser') &&
!empty($_REQUEST['verify']) &&
if($_REQUEST['secret'] != "SOMESECRETHERE")
wp_die("Invalid secret.");
$user = get_user_by("email", str_replace(" ", "+", ($_REQUEST['verify'])));
wp_die("User not found.");
$membership_level = pmpro_getMembershipLevelForUser();
//user and membership level found, output json encoded membership level info
echo json_encode($membership_level);
add_action('init', 'my_init_pmpro_mini_api');

This comment has been minimized.

Copy link

@Awzaw Awzaw commented Jan 27, 2020

Hi, I think should be:

$membership_level = pmpro_getMembershipLevelForUser($user->ID);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment