pmpro_xmlrpc_getMembershipLevelForUser

API method to get the membership level info for a user.

Description

pmpro_xmlrpc_getMembershipLevelForUser( $args ); 

Since v2.0

Parameters (1)

0. $args
The args.

Usage

  1. if ( !function_exists( 'pmpro_xmlrpc_getMembershipLevelForUser' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/xmlrpc.php'; 
  3.  
  4. // The args. 
  5. $args = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = pmpro_xmlrpc_getMembershipLevelForUser($args); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/xmlrpc.php  
  1. function pmpro_xmlrpc_getMembershipLevelForUser($args) 
  2. // Parse the arguments, assuming they're in the correct order 
  3. $username = $args[0]; 
  4. $password = $args[1]; 
  5. $user_id = $args[2]; //optional user id passed in 
  6.  
  7. global $wp_xmlrpc_server; 
  8.  
  9. // Let's run a check to see if credentials are okay 
  10. if ( !$user = $wp_xmlrpc_server->login($username, $password) ) { 
  11. return $wp_xmlrpc_server->error; 
  12.  
  13. // The user passed should be an admin or have the pmpro_xmlprc capability 
  14. if(!user_can($user->ID, "manage_options") && !user_can($user->ID, "pmpro_xmlrpc")) 
  15. return "ERROR: User does not have access to the PMPro XMLRPC methods."; 
  16.  
  17. // Default to logged in user if no user_id is given. 
  18. if(empty($user_id)) 
  19. {  
  20. $user_id = $user->ID; 
  21.  
  22. $membership_level = pmpro_getMembershipLevelForUser($user_id); 
  23.  
  24. return $membership_level;