Support

Home Forums Event Espresso Premium On payment confirmation – run custom function depending on Event Custom Field

On payment confirmation – run custom function depending on Event Custom Field

Posted: December 13, 2019 at 11:05 am


a608237

December 13, 2019 at 11:05 am

I’d just like to ask this question before I got lost in the weeds and end up asking hours down the road eventually.

How can I automatically fire a function that creates a buddypress group from the string of an Event Espresso registration field conditional on an Event Espresso custom field?

I run two types of events: individual and group. I denote these using Event Espresso Custom Field sp_format. i.e. sp_format = 1 = individual, sp_format = 2 = grou (Is this the correct use of these custom fields)?

For group events sp_format = 2, I also have a specific Question Group which contains a text field Group for the registrant to submit their group name.

On payment confirmation, how can I check if sp_format = 2 and Group field is not null then create_buddypress_group?

In some research, this action hook fires when payment is confirmed AHEE__EE_Gateway__update_transaction_with_payment__done and the buddypress function groups_create_group can be passed an array to create a group during the hook (i think).. but how might I check sp_format as well as retrieve the Group field in the Registration object (is there an object?) to determine whether my custom function should be ran or not?

Thanks in advance.


Tony

  • Support Staff

December 16, 2019 at 6:05 am

Hi there,

Maybe I’m completely missing it, but I can’t find AHEE__EE_Gateway__update_transaction_with_payment__done in the EE codebase, where did you see that hook?

The hook I would use is AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful to run ONLY on a successful payment.

There is also AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment which runs after checkout finalizes or a payment is made.

—-

The above actions are both passed the transaction object and from that, you can pull the event(s), meaning you can pull your custom field.

You do that using the methods available on models and we have some documentation on using those here:

https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System

The support post ‘On payment confirmation – run custom function depending on Event Custom Field’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso