Support

Home Forums Event Espresso Premium Hook on successful registration – not working every time

Hook on successful registration – not working every time

Posted: September 4, 2017 at 10:01 am

Viewing 2 reply threads


Source Design

September 4, 2017 at 10:01 am

Ref previous post: https://eventespresso.com/topic/best-action-hook-for-running-code-after-successful-registration/

I’ve got a plugin I’ve written that hooks into the “AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed” action hook with EE4.

The idea of the plugin is that, when an event registration is completed, details about the event and the attendee get sent through to my client’s CRM package via an API.

For some registrations, this works fine. However, not every registration triggers the hook above (or, at least, if it does the code doesn’t run)

A (condensed) version of my code:

add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'after_registration', 10, 2 );

function after_registration( $checkout, $txn_update_params ) {
	$fp = fopen( $logs_dir . "/ee4-checkout-" . date('Y-m-d-H-i-s') . ".log", "ab" );
	if ( $fp ) {
		fputs( $fp, "[" . date('H:i:s') . "] Event registration received dumping checkout object.\r\n" );
		fputs( $fp, print_r( $checkout, true ) . "\r\n" );
		fclose($fp);
	}
}

I get log files turning up in the folder, but every so often a registration comes through (and the client gets an email confirmation from EE4) but an associated log doesn’t show up in the logs folder.

Am I using the wrong hook? Are there situations where this hook doesn’t fire?

Any help appreciated. Thanks.

  • This topic was modified 7 years, 1 month ago by Tony. Reason: code formatting


Source Design

September 4, 2017 at 10:02 am

Bah, could someone fix the formatting please? Assume I was supposed to use blockquote rather than code.


Josh

  • Support Staff

September 5, 2017 at 8:40 am

Hi there,

I can recommend opening an issue on Github where it will help if you can post the full code and if at all possible a unit test that demonstrates the issue:

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

Viewing 2 reply threads

The support post ‘Hook on successful registration – not working every time’ 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