pmpro_getMemberStartdate

The Paid Memberships Pro pmpro getMemberStartdate function.

Description

pmpro_getMemberStartdate( (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_getMemberStartdate' ) ) { 
  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_getMemberStartdate($user_id, $level_id); 
  12.  

Defined (1)

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

/includes/functions.php  
  1. function pmpro_getMemberStartdate($user_id = NULL, $level_id = 0) 
  2. if(empty($user_id)) 
  3. global $current_user; 
  4. $user_id = $current_user->ID; 
  5.  
  6. //make sure user and level id are int for security 
  7. $user_id = intval($user_id); 
  8. $level_id = intval($level_id); 
  9.  
  10. global $pmpro_startdates; //for cache 
  11. if(empty($pmpro_startdates[$user_id][$level_id])) 
  12. global $wpdb; 
  13.  
  14. if(!empty($level_id)) 
  15. $sqlQuery = "SELECT UNIX_TIMESTAMP(startdate) FROM $wpdb->pmpro_memberships_users WHERE status = 'active' AND membership_id IN(" . esc_sql($level_id) . ") AND user_id = '" . $user_id . "'ORDERBY id LIMIT 1"; 
  16. else 
  17. $sqlQuery = "SELECT UNIX_TIMESTAMP(startdate) FROM $wpdb->pmpro_memberships_users WHERE status = 'active' AND user_id = '" . $user_id . "'ORDERBY id LIMIT 1"; 
  18.  
  19. $startdate = apply_filters("pmpro_member_startdate", $wpdb->get_var($sqlQuery), $user_id, $level_id); 
  20.  
  21. $pmpro_startdates[$user_id][$level_id] = $startdate; 
  22.  
  23. return $pmpro_startdates[$user_id][$level_id];