pmpro_getMemberDays

The Paid Memberships Pro pmpro getMemberDays function.

Description

pmpro_getMemberDays( (constant) $user_id = NULL, (int) $level_id = 0 ); 

Parameters (2)

0. $user_id — Optional. (constant) => NULL
The user id.
1. $level_id — Optional. (int)
The level id.

Usage

  1. if ( !function_exists( 'pmpro_getMemberDays' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/functions.php'; 
  3.  
  4. // The user id. 
  5. $user_id = NULL; 
  6.  
  7. // The level id. 
  8. $level_id = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = pmpro_getMemberDays($user_id, $level_id); 
  12.  

Defined (1)

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

/includes/functions.php  
  1. function pmpro_getMemberDays($user_id = NULL, $level_id = 0) 
  2. if(empty($user_id)) 
  3. global $current_user; 
  4. $user_id = $current_user->ID; 
  5.  
  6. global $pmpro_member_days; 
  7. if(empty($pmpro_member_days[$user_id][$level_id])) 
  8. $startdate = pmpro_getMemberStartdate($user_id, $level_id); 
  9.  
  10. //check that there was a startdate at all 
  11. if(empty($startdate)) 
  12. $pmpro_member_days[$user_id][$level_id] = 0; 
  13. else 
  14. $now = current_time('timestamp'); 
  15. $days = ($now - $startdate)/3600/24; 
  16.  
  17. $pmpro_member_days[$user_id][$level_id] = $days; 
  18.  
  19. return $pmpro_member_days[$user_id][$level_id];