First you will need to have the plugin installed (paidmembershipspro ) otherwise you wont be able to call the function “pmpro_getMembershipLevelForUser” and then you just need to copy the code below to your functions.php file which is inside your WordPress theme.
/*
Call to http://yoursite.com/[email protected]&secret=CHECK to
check the membership level of a user.
*/
function my_init_pmpro_mini_api()
{
if(function_exists('pmpro_getMembershipLevelForUser') &&
!empty($_REQUEST['verify']) &&
!empty($_REQUEST['secret']))
{
if($_REQUEST['secret'] != "CHECK")
wp_die("Invalid secret.");
$user = get_user_by("email", str_replace(" ", "+",
($_REQUEST['verify'])));
if(empty($user))
wp_die("User not found.");
$membership_level = pmpro_getMembershipLevelForUser();
if(empty($membership_level))
die("0");
//user and membership level found, output json encoded membership level
info
echo json_encode($membership_level);
exit;
}
}
add_action('init', 'my_init_pmpro_mini_api');