Support

Home Forums Pre-Sales Split: Hooks in EE4

Split: Hooks in EE4

Posted: September 9, 2015 at 12:02 pm


Alan Coyne

September 9, 2015 at 12:02 pm

I want to call a webservice whan an attendee registers successfully.For this, I am looking to add my custom hook/function to be called after ‘AHEE__EE_Registration_Processor__trigger_registration_update_notification’, but not know in which file to add the hook so that it not be affected during updating the plugin.


Josh

  • Support Staff

September 9, 2015 at 1:57 pm

Hi Alan,

If you’re going to use a hook that already exists in Event Espresso 4, you can add your function to your own plugin. There’s some documentation on how to set up a custom plugin from scratch here:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/“>

If you need to add a hook to Event Espresso 4 core, we welcome pull requests. You can submit a pull request via github:

https://github.com/eventespresso/event-espresso-core/issues


Alan Coyne

September 10, 2015 at 7:29 am

Thanks Josh for the updates.
One more thing want to clear that when an attendee registers successfully how to get that registration’s details to use it in the custom hook. I want to send the registration detail to third party on successful registration(currently writing in log.txt).
I have added the action createpage() in my custom plugin as below.But it says error “Method get_one() in class EE_Registration does not exist’.

add_action(‘AHEE__EE_Registration_Processor__trigger_registration_update_notifications’,’createpage’);
function createpage(){
$registration = EE_Registration::new_instance()->get_one();
$s = $registration->get(‘ATT_ID’);
file_put_contents(ABSPATH.’log.txt’,’testing’.$s.);
}


Josh

  • Support Staff

September 10, 2015 at 8:12 am

It’s correct that there isn’t a get_one() method in the EE_Registration class. You can try using the get_primary_registration() method.


Alan Coyne

September 10, 2015 at 1:08 pm

I use the get_primary_registration(),then it gives 0 for all field’s value.
$registration = EE_Registration::new_instance()->get_primary_registration();
$s = $registration->get(‘REG_ID’);
file_put_contents(ABSPATH.’log.txt’,’testing’.$s);


Josh

  • Support Staff

September 10, 2015 at 1:49 pm

Hi Alan,

It turns out this is a bit outside the scope of support. If you suspect there’s an issue with one of the models or methods you’re welcome to open up an issue on the Github issue tracker, and one of the developers will follow up with you there:

https://github.com/eventespresso/event-espresso-core/issues


Alan Coyne

September 14, 2015 at 5:54 am

Thanks Josh, I got the solution from github as below:
add_action( ‘AHEE__EE_Registration_Processor__trigger_registration_update_notifications’, ‘createpage’, 10, 2 );
function createpage( $registration, $additional_details ) {
if ( $registration instanceof EE_Registration ) {
//do stuff with the $registration object.
}
}


Josh

  • Support Staff

September 14, 2015 at 10:28 am

Hi Alan,

Do you have a link to the github issue so the dev team can follow up there?


Alan Coyne

September 14, 2015 at 11:25 am

https://github.com/eventespresso/event-espresso-core/issues/116#issuecomment-139532745


Josh

  • Support Staff

September 14, 2015 at 12:19 pm

Thanks, that’s a good place to post your follow up questions to.

The support post ‘Split: Hooks in EE4’ 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