Support

Home Forums Event Espresso Premium Assigning custom email at category level

Assigning custom email at category level

Posted: July 13, 2020 at 7:41 pm


sosfirstaid.ca

July 13, 2020 at 7:41 pm

I would like to be able to apply custom emails to an entire category of events, rather than a single event at a time. Is there a way I can do this, whether it’s via add-on, or custom code, or anything? Thanks for your help.


Tony

  • Support Staff

July 15, 2020 at 7:17 am

Hi there,

There’s a couple of ways you can do this and whilst it’s not something we can support and can help point you in the right direction.

(Note – both of these options require custom code as we don’t have anything in core that can do it for you)

Option 1 – Hook into the function used to generate the email data and set the send_email and email_id property of the event on the fly.

There’s a within EE3 ‘fired’ just after EE has prepped all of the data it will use for the email which is filter_hook_espresso_post_prepare_email_data.

So you could hook into that, pull the event ID from $data and find the event category. If that matches the category in question set the send_email and email_id properly.

Take a look in \event-espresso\includes\functions\email.php line 328 for the filter and it you step through the data above it shows a similar setup.

This is the easiest option but adds an additional query to each and every email as it needs to check the category each time.

Option 2 – Update the event’s within the database to use custom email.

Within each event record there is a send_email and email_id field. Setting send_email to ‘Y’ and then the email_id field to the ID of the email you want to send for that event will tell EE which email to use.

So if this is a one time update you could write some custom code to pull all of the events in said category, loop over each and update the 2 fields above. Depending on the number of events this may need to be done in batches.

This is a little more involved but you only need to run the query to update the events once, not every time an email is generated.

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: publish

Updated by  Tony 3 weeks, 6 days ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!