pmpro_isLevelExpiringSoon

Is this level expiring within one pay period.

Description

pmpro_isLevelExpiringSoon( (object) &$level ); 

Parameters (1)

0. $level (object) => &$level
PMPro Level Object to test

Usage

  1. if ( !function_exists( 'pmpro_isLevelExpiringSoon' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/functions.php'; 
  3.  
  4. // PMPro Level Object to test 
  5. $level = &$level; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = pmpro_isLevelExpiringSoon($level); 
  9.  

Defined (1)

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

/includes/functions.php  
  1. function pmpro_isLevelExpiringSoon( &$level ) { 
  2. if( !pmpro_isLevelExpiring( $level ) || empty( $level->enddate ) ) 
  3. $r = false; 
  4. else { 
  5. //days til expiration for the standard level 
  6. $standard = pmpro_getLevel( $level->id ); 
  7.  
  8. if( !empty( $standard->expiration_number ) ) { 
  9. if( $standard->expiration_period == 'Day' ) 
  10. $days = $level->expiration_number; 
  11. elseif( $standard->expiration_period == 'Week' ) 
  12. $days = $level->expiration_number * 7; 
  13. elseif( $standard->expiration_period == 'Month' ) 
  14. $days = $level->expiration_number * 30; 
  15. elseif( $standard->expiration_period == 'Year' ) 
  16. $days = $level->expiration_number * 365; 
  17. else 
  18. $days = 30; 
  19.  
  20. //are we within the days til expiration? 
  21. $now = current_time('timestamp'); 
  22.  
  23. if( $now + ($days*3600*24) >= $level->enddate ) 
  24. $r = true; 
  25. else 
  26. $r = false; 
  27.  
  28. //filter 
  29. $r = apply_filters('pmpro_is_level_expiring_soon', $r, $level); 
  30.  
  31. return $r;