get_last_transaction_for_user_and_sub

The Membership 2 get last transaction for user and sub function.

Description

get_last_transaction_for_user_and_sub( $user_id, $sub_id ); 

Parameters (2)

0. $user_id
The user id.
1. $sub_id
The sub id.

Usage

  1. if ( !function_exists( 'get_last_transaction_for_user_and_sub' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'membership-2/app_old/membershipincludes/includes/functions.php'; 
  3.  
  4. // The user id. 
  5. $user_id = null; 
  6.  
  7. // The sub id. 
  8. $sub_id = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = get_last_transaction_for_user_and_sub($user_id, $sub_id); 
  12.  

Defined (1)

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

/app_old/membershipincludes/includes/functions.php  
  1. function get_last_transaction_for_user_and_sub($user_id, $sub_id) { 
  2.  
  3. global $wpdb; 
  4.  
  5. $sql = $wpdb->prepare( "SELECT * FROM " . membership_db_prefix($wpdb, 'subscription_transaction') . " WHERE transaction_user_ID = %d and transaction_subscription_ID = %d ORDER BY transaction_stamp DESC LIMIT 0, 1", $user_id, $sub_id ); 
  6.  
  7. return $wpdb->get_row( $sql ); 
  8.