- This topic has 3 replies, 2 voices, and was last updated 2 years, 10 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘How do I …’ is closed to new topics and replies.
Events Made Easy › Forums › How do I … › Use EME Templates with eme_send_mail function?
Hello Franky,
I’m still experimenting with some action hooks and filters and was wondering if I could have the eme_send_mail function use EME templates for subject and body, instead of creating these in my hook function? I’d like to use a more elaborate email body and keeping the template separate would keep it a tad more manageable
Not a big deal if not, just wanted to ask…
eme_send_mail is a generic function, also used for memberships, tasks, generic mails etc … so not just events.
You could call eme_get_template_format_plain (which is eme_get_template_format but making sure no nl2br translation happens) with the template id as argument. After that replace the placeholders in it, by calling eme_replace_booking_placeholders on it (using also $event and $booking). E.g. for template id 1 for subject and 2 for content:
$my_subject_format=eme_get_template_format_plain(1);
$my_actual_subject=eme_replace_booking_placeholders($my_subject_format, $event, $booking, 0, "text");
$my_content_format=eme_get_template_format_plain(2);
$my_actual_content=eme_replace_booking_placeholders($my_content_format, $event, $booking);
Fantastic!
Did all sorts of testing and optimizing my templates. But it really works like a charm!#
Just to clarify – in your example there’s difference in the code for the second eme_replace_booking_placeholders function
The first contains 2 more arguments: “0, “text”). I guess we need “text” or “html” at the end, right? But what does the “0” stand for?
Thanks again!
The 0 indicates it is not related to a multibooking (not relevant for you I’d say) and is the default, but for the subject I want to make sure it is text-only, so I need the following parameter (“text”) and therefore I also need to specify the 0. In php 8 one has named parameters, but since not everyone is on php 8 I can’t use those (yet).