Posted: August 1, 2020 at 1:08 pm
I have the need to stop some individual datetime reminder emails for a class from sending while allowing others through.
I have used customized shortcodes to create a wide range of new functionality in our reminder emails (and other emails) so kudos to you guys for creating such a flexible system. I am constantly amazed by what is possible!
For instance, here is one code snippet where we look up a meta value on an event and then insert a shortcode if it exists.
So, I know there are datetime-specific and event-specific shortcodes… but can I make a registration-specific shortcode that can be applied to a shortcode like [RECIPIENT_EMAIL] that is normally in the TO field?
What I’d like to do is simply stop an email from sending based on a user’s registration question answers. For instance, if they choose “do not send me reminder emails” on our question form in checkout I want to stop the email from sending to them. I had an idea that I could customize the [RECIPIENT_EMAIL] to be something like [CUSTOM_RECIPIENT_EMAIL_BASED_ON_QUESTION] and then simply route the email to a “dead-letter” email address thereby stopping delivery of the email.
Is this possible to use a custom EVENT context shortcode in the TO field?
Sure you can.
Take a look in
You may also want to look into the
Side note, you’re now getting into the a library that is usually passed an
Just return an empty string
Possible, yes, but event-specific shortcodes won’t help you here unless I’m misunderstanding.
Event shortcodes would be things like
Great! I was missing the insight that each “section” of the email has its own class that is passed parser data. The EE_Recipient_Details_Shortcodes is the class I was looking for – thanks!
I added this to the shortcodes after parser filter (not sure if I need all of the “instanceof” ternary operations at the beginning, but I can confirm that this code works when added to a ‘FHEE__EE_Shortcodes__parser_after’ hook and added to the list of shortcodes in ‘FHEE__EE_Shortcodes__shortcodes’):
Any feedback on this code welcome!
Your current code can’t do anything without an
You can also check for an
What you have should work anyway so up to you, now it’s just a case of pulling a value for the registration question and doing whatever you need from there.