I'm trying to integrate an Android and Windows APP with my site. At this point, I am working 'offline' at my windows localhost site. Everything seems to be set up properly. I have 3 users: Wordpress admin + two others. I have set 2 membership levels - one free one paid. I need to get the level(s) for a user by his email address.

I have added the following to the theme functions.php file:

Call to http://yoursite.com/?verify=email@domain.com&secret=CHECK 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'] != "CHECK")
      wp_die("Invalid secret.");

      $user = get_user_by("email", str_replace(" ", "+",($_REQUEST['verify'])));
      wp_die("User not found.");

    $membership_level = pmpro_getMembershipLevelForUser();
      wp_die("Membership Level Empty");

  //user and membership level found, output json encoded membership level info;
  echo json_encode($membership_level);        

add_action('init', 'my_init_pmpro_mini_api');

The only response I get, besides for unknown user is the "Membership Level Empty". It knows that the user is valid, but it does not return anything useful.

Any pointer would be apreciated


pmpro_getMembershipLevelForUser returns membership level for current user if parameter is not specified, and it will be anonymous user with high probability (depending on how you call it).



instead of


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.