Support

Home Forums Event Espresso Premium Making the Mailchimp eventdate code snippet filter by category

Making the Mailchimp eventdate code snippet filter by category

Posted: October 12, 2022 at 8:50 am

Viewing 1 reply thread


Brooke

October 12, 2022 at 8:50 am

Hi,

I’m using the snippet on the link below to send the eventdate to Mailchimp. How would I be able to filter the snippet so it only runs for a selected category within EE4?

https://github.com/eventespresso/ee-code-snippet-library/blob/master/addons/eea-mailchimp/tw_eea_mailchimp_start_date.php

To explain, I run both courses and social events and I have a category for each in EE4. So if I want a snippet to only run when a course is booked, how could I do that?

Thanks, Brooke


Tony

  • Support Staff

October 12, 2022 at 4:39 pm

Hi there,

One option for this is to add something like this:

$term_obj_list = get_the_terms( $EVT_ID, 'espresso_event_categories' );
$terms_array = wp_list_pluck($term_obj_list, 'name');

if( ! in_array( 'courses', $terms_array ) ) {
    //This event NOT set to be within the course category.
    return $subscribe_args;
}

Add that snippet on line 8 of that snippet.

Viewing 1 reply thread

The support post ‘Making the Mailchimp eventdate code snippet filter by category’ 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