Lorenzo Orlando Caum
|
September 9, 2020 at 1:27 pm
I am using the AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful hook in order to do some custom coding with regards to events.
What I ultimately need to do is to get the event id that the transaction/registration was done for; as I want to update the access list for the specific event page when a registration is done and paid for (there is already a page associated with the event, which is already coded and working fine).
I can see in the source code for EE_Payment_Processor.core.php that it passes the payment and transaction objects to the hook.
What I have so far:
add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful', 'evt_add_reg', 10, 2); // I first tried without the extra parameters, but also didn't work
function evt_add_reg($transaction, $payment)
{
global $wpdb;
wp_mail('john-henry@dieselbrook.co.za', 'test', 'test'); //this does fire off, meaning that the hook does work
$payment_object = $payment instanceof EE_Payment ? $payment : null;
$event = $payment_object->get_first_event(); //this will get the event?
$event_id = $event->ID();
wp_mail('john-henry@dieselbrook.co.za', 'test object', $payment_object); //this doesn't work, meaning that it can't find the data
}
I have also tried using the passed parameters directly, which didn’t work:
function evt_add_reg($transaction, $payment)
{
global $wpdb;
wp_mail('john-henry@dieselbrook.co.za', 'test', 'test'); // the same applies as above
$payment_object = $payment instanceof EE_Payment ? $payment : null;
$event = $payment_object->get_first_event();
$event_id = $event->ID();
wp_mail('john-henry@dieselbrook.co.za', 'test object', $payment); // the same applies as above
}
Please let me know if the data is structured differently, and if I should adapt my code in order to get the ID (or if there is an easier way to get the id).
|