pmpro_set_current_user

The Paid Memberships Pro pmpro set current user function.

Description

pmpro_set_current_user(); 

Usage

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

Defined (1)

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

/includes/init.php  
  1. function pmpro_set_current_user() 
  2. //this code runs at the beginning of the plugin 
  3. global $current_user, $wpdb; 
  4. wp_get_current_user(); 
  5. $id = intval($current_user->ID); 
  6. if($id) 
  7. $current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID); 
  8. if(!empty($current_user->membership_level)) 
  9. $current_user->membership_level->categories = pmpro_getMembershipCategories($current_user->membership_level->ID); 
  10. $current_user->membership_levels = pmpro_getMembershipLevelsForUser($current_user->ID); 
  11.  
  12. //hiding ads? 
  13. $hideads = pmpro_getOption("hideads"); 
  14. $hideadslevels = pmpro_getOption("hideadslevels"); 
  15. if(!is_array($hideadslevels)) 
  16. $hideadslevels = explode(", ", $hideadslevels); 
  17. if($hideads == 1 && pmpro_hasMembershipLevel() || $hideads == 2 && pmpro_hasMembershipLevel($hideadslevels)) 
  18. //disable ads in ezAdsense 
  19. if(class_exists("ezAdSense")) 
  20. global $ezCount, $urCount; 
  21. $ezCount = 100; 
  22. $urCount = 100; 
  23.  
  24. //disable ads in Easy Adsense (newer versions) 
  25. if(class_exists("EzAdSense")) 
  26. global $ezAdSense; 
  27. $ezAdSense->ezCount = 100; 
  28. $ezAdSense->urCount = 100; 
  29.  
  30. //set a global variable to hide ads 
  31. global $pmpro_display_ads; 
  32. $pmpro_display_ads = false; 
  33. else 
  34. global $pmpro_display_ads; 
  35. $pmpro_display_ads = true; 
  36.  
  37. do_action("pmpro_after_set_current_user");