pmpro_checkout_start_date_keep_startdate

If checking out for the same level, keep your old startdate.

Description

pmpro_checkout_start_date_keep_startdate( $startdate, $user_id, $level ); 

Added with 1.5.5

Parameters (3)

0. $startdate
The startdate.
1. $user_id
The user id.
2. $level
The level.

Usage

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

Defined (1)

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

/includes/filters.php  
  1. function pmpro_checkout_start_date_keep_startdate($startdate, $user_id, $level) 
  2. {  
  3. if(pmpro_hasMembershipLevel($level->id, $user_id)) 
  4. global $wpdb; 
  5. $sqlQuery = "SELECT startdate FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . esc_sql($user_id) . "' AND membership_id = '" . esc_sql($level->id) . "' AND status = 'active'ORDERBY id DESC LIMIT 1";  
  6. $old_startdate = $wpdb->get_var($sqlQuery); 
  7.  
  8. if(!empty($old_startdate)) 
  9. $startdate = "'" . $old_startdate . "'"; 
  10.  
  11. return $startdate;