pmpro_getLTV

The Paid Memberships Pro pmpro getLTV function.

Description

pmpro_getLTV( $period, (string) $levels = 'all', (constant) $mrr = NULL, (constant) $signups = NULL, (constant) $cancellation_rate = NULL ); 

Parameters (5)

0. $period
The period.
1. $levels — Optional. (string) => 'all'
The levels.
2. $mrr — Optional. (constant) => NULL
The mrr.
3. $signups — Optional. (constant) => NULL
The signups.
4. $cancellation_rate — Optional. (constant) => NULL
The cancellation rate.

Usage

  1. if ( !function_exists( 'pmpro_getLTV' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/adminpages/reports/memberships.php'; 
  3.  
  4. // The period. 
  5. $period = null; 
  6.  
  7. // The levels. 
  8. $levels = 'all'; 
  9.  
  10. // The mrr. 
  11. $mrr = NULL; 
  12.  
  13. // The signups. 
  14. $signups = NULL; 
  15.  
  16. // The cancellation rate. 
  17. $cancellation_rate = NULL; 
  18.  
  19. // NOTICE! Understand what this does before running. 
  20. $result = pmpro_getLTV($period, $levels, $mrr, $signups, $cancellation_rate); 
  21.  

Defined (1)

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

/adminpages/reports/memberships.php  
  1. function pmpro_getLTV($period, $levels = 'all', $mrr = NULL, $signups = NULL, $cancellation_rate = NULL) 
  2. {  
  3. if(empty($mrr)) 
  4. $mrr = pmpro_getMRR($period, $levels); 
  5. if(empty($signups)) 
  6. $signups = pmpro_getSignups($period, $levels); 
  7. if(empty($cancellation_rate)) 
  8. $cancellation_rate = pmpro_getCancellationRate($period, $levels); 
  9.  
  10. //average monthly spend 
  11. if(empty($signups)) 
  12. return false; 
  13.  
  14. if($signups > 0) 
  15. $ams = $mrr / $signups; 
  16. else 
  17. $ams = 0; 
  18.  
  19. if($cancellation_rate > 0) 
  20. $ltv = $ams * (1/$cancellation_rate); 
  21. else 
  22. $ltv = $ams; 
  23.  
  24. return $ltv;