Support

Home Forums Event Espresso Premium ConstantContact integration

ConstantContact integration

Posted: June 20, 2018 at 12:38 pm

Viewing 5 reply threads


Drio LLC

June 20, 2018 at 12:38 pm

I have added a checkbox field to the “Personal Information” Question Group, asking if a user wants to sign up to the ConstantContact email list for that event. I have the PHP knowledge to create the ConstantContact integration using their API, but I don’t know where the custom PHP code should go within EE to pick up whether the checkbox was checked or not. Is there a hook/filter that I can tap into in my child theme that executes when the registration form is submitted?


Josh

  • Support Staff

June 20, 2018 at 2:59 pm

Hi,

You could use either of the following action hooks:

AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed
AHEE__EE_Single_Page_Checkout__process_attendee_information__end

I can advise to add the custom code into its own plugin for the purpose of better organized code. Also if you ever switch themes that will be one less chunk of code to move over. More info here:
https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/


Drio LLC

June 20, 2018 at 4:52 pm

Thank you, Josh. In my callback function, what the are parameters I need to pass to it to get the registration information (name, email, etc.) and the event ID?


Josh

  • Support Staff

June 20, 2018 at 5:22 pm

It will depend on which hook you end up using. You can check the source files for those hooks to see the available parameters.
https://github.com/eventespresso/event-espresso-core/blob/master/modules/single_page_checkout/reg_steps/attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php#L937

https://github.com/eventespresso/event-espresso-core/blob/master/modules/single_page_checkout/reg_steps/finalize_registration/EE_SPCO_Reg_Step_Finalize_Registration.class.php#L89

Along with that, I can recommend reviewing the source files of the MailChimp add-on because you’ll be replicating the functionality of that plugin. The main difference is you’ll be making API calls to ConstantContact instead of the MailChimp API.


Drio LLC

June 22, 2018 at 6:47 pm

I’m trying to verify that I’m getting the registration information with the following code:

function cc_integration( EE_Registration $registration, $valid_data = array() ){
$testreg = print_r( $registration, true );
file_put_contents( ‘testreg.txt’, $testreg );
}
add_action( ‘AHEE__EE_Single_Page_Checkout__process_attendee_information__end’, ‘cc_integration’, 1, 2 );

However, I’m not getting the output written to testreg.txt even with full write permissions on the testreg.txt. Is my approach correct to capture the registration information and is there a better way to test the action?


Tony

  • Support Staff

June 25, 2018 at 6:23 am

Are you adding that code to a custom function plugin?

If you view your server’s error logs when using the above, you’ll see a fatal error.

You are currently casing the first parameter to be an EE_Registration object, but its not:

function cc_integration( EE_Registration $registration, $valid_data = array() ){

This is the action within core:

do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);

Thats from within the EE_SPCO_Reg_Step_Attendee_Information class, so $this will be an istance of EE_SPCO_Reg_Step_Attendee_Information, not EE_Registration.

The best way to follow how to use that hook is to take a look at the MaiLChimp add-on, that hooks in with espresso_mailchimp_submit_to_mc and then calls mci_submit_to_mailchimp( $spc_obj, $spc_data ) to extract the registrations before submitting to MailChimp. You need to follow similar steps that that code.

Viewing 5 reply threads

The support post ‘ConstantContact integration’ 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