Posted: February 8, 2016 at 9:35 am
|
Hello, I have ACF Pro field on events to regsiter specific email for each event.
How can I declare it as a shortcode usable in EE4 custom email ? How can I c |
Hi there, Take a look here: https://gist.github.com/Pebblo/e87cc8e30c4848dcdfe2 That gist outlines how you can add custom shortcodes to the EE4 Messages system. Your shortcode would be an Event based shortcode, so it would be registered in the same way as [TONYS_EVENT_SHORTCODE] and then parsed further down within the EE_Event_Shortcodes. Does that help? |
|
|
It seems to be the good direction. For the moment I got some bugs just to diplay it. I have creat and activate the plugin. But any new shortcode appears on my email template.
Have you an idea ? |
|
Well, it is available in all message shorcods but I can’t use it on email. I’m keep looking. |
|
I can use it on [EVENT_LIST] part of an email. |
Event Espresso already allows you to use specific email addresses for each event by setting the author of the event to the users account and using the [EVENT_AUTHOR_EMAIL] Event based emails are not available within the TO and FROM sections (as you’ve found above) and those sections are trickier than the others as the data passed to the shortcodes can be for multiple events. So the you’ll need to loop through and build the correct data you need. Take a look at how the EE_Email_Shortcodes are parsed within the core code and you’ll see something similar with the EVENT_AUTHOR_EMAIL shortcode with how its parsed for the events passed to the shortcode parser for EE_Email_Shortcodes. EE_Email_Shortcodes is passed the EE_Messages_incoming_data object, take a look at that class within core and you’ll see the properties available for the class. You’ll want to pull in all of the event ID’s from the EE_Messages_incoming_data object, loop through each event and pull in the meta value using that events ID. Then return a comma-delimited string of email address for the message to use. Can you not set the Event Author for the event to the user that created the event and then just use the default [EVENT_AUTHOR_EMAIL] shortcode within the messages? |
|
|
Thanks for your answer. I will try to investigate. We need another email per event for two reasons. If I understand, you think its to tricky to add custom email from event within the TO message ? |
One way to achieve this is to create custom message templates, assign the email address you wish for the emails to be sent to to those custom templates and select the template within the event.
Tricky in the sense that you don’t know the exact event, or how many events will be passed to the shortcode parser, which means you can’t just do something like this:
and expect that to be the correct email address. A single notification can be used for multiple events, so the tricky party is making sure you first have the event(s) to pull the event meta from and also that if there are multiple events select that the shortcode handles that correctly. As mentioned above take a look within \core\libraries\shortcodes\EE_Email_Shortcodes.lib.php around line 101 you’ll find _get_event_admin_emails() That does something similar for the event admin emails, your shortcode would be very similar to this, only it would loop through the events and pull the ’email_event_field’ meta value. Then use that value to build a string of email address for the message to be sent to. |
|
The support post ‘EE4 – Create Shortcode to insert it on Email template – With ACF Pro’ 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.