getUserFromInvoiceEvent

The Paid Memberships Pro getUserFromInvoiceEvent function.

Description

getUserFromInvoiceEvent( $pmpro_stripe_event ); 

Parameters (1)

0. $pmpro_stripe_event
The pmpro stripe event.

Usage

  1. if ( !function_exists( 'getUserFromInvoiceEvent' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/services/stripe-webhook.php'; 
  3.  
  4. // The pmpro stripe event. 
  5. $pmpro_stripe_event = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = getUserFromInvoiceEvent($pmpro_stripe_event); 
  9.  

Defined (1)

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

/services/stripe-webhook.php  
  1. function getUserFromInvoiceEvent($pmpro_stripe_event) 
  2. //pause here to give PMPro a chance to finish checkout 
  3.  
  4. global $wpdb; 
  5.  
  6. $customer_id = $pmpro_stripe_event->data->object->customer; 
  7.  
  8. //look up the order 
  9. $user_id = $wpdb->get_var("SELECT user_id FROM $wpdb->pmpro_membership_orders WHERE subscription_transaction_id = '" . esc_sql($customer_id) . "' LIMIT 1"); 
  10.  
  11. if(!empty($user_id)) 
  12. return get_userdata($user_id); 
  13. else 
  14. return false;