daberelay
Forum Replies Created
-
Damian, do you maybe have an Idea how to fix this issue?
To clarify, this is the main problem:
The “to” parameter is not passed on through your code to the placeholders list.the only way I can circumvent that, is by manipulating the code to add it (step 3 of my original post here).
Can you suggest a non-intrusive way of getting the “to” parameter in the placeholder’s list while enjoying safe future upgrades?
thanks!
also, It strikes me odd, and indeed doesn’t sit well with the filter function that you pass different types of objects as the $args second parameter:
on send_email: you pass $phpmailer to the replace placeholder as second parameter, and $message as the first one.
$phpmailer->Body = $this->replace_placeholders( $message, $phpmailer );
to the altBody, you only pass the original body (the email_content filter has no impact).
$phpmailer->AltBody = $this->replace_placeholders( strip_tags($phpmailer->Body) );on send_email_generic and send_email_postman:
$this->replace_placeholders( $temp_message, $message (or $args) );
you pass $message/$args as second parameter which is an array, not an object.I believe that passing $phpmailer is mistake, the filter shouldn’t be aware of that object…
Hi Damian,
Thanks for fixing this up in v1.2, but we’re still around the same issue.
The “to” parameter is not passed on through your code to the placeholders list.
the only way I can circumvent that, is by manipulating the code to add it (step 3 of my original post here).
Can you suggest a non-intrusive way of getting the “to” parameter in the placeholder’s list while enjoying safe future upgrades?
thanks in advance,
NimrodHi Damian,
As I suspected, this is not a viable solution, since the $args are not passed to the filter, and therefore I don’t have the addressee information within the filter.Would you consider a fix? I’m sure many will enjoy being able to provide a user/email-address-aware email templates…
thanks Damian!
I wasn’t aware that I could use the $args in the filter, good to know.
will test now.
thanks again ??
Nimrod.To whoever needs it like me, and still waits for the developers to provide a solution, here’s what you can do.
1. Clone the plugin, and rename its package ID so it won’t get overrun in future updates.
2. edit the replace_placeholders function in /email-templates/includes/class-mailtpl-mailer.php to receive another argument called $args, and merge these args into the list of keys=>values that the plugin supports:private function replace_placeholders( $email,$args = array() ) { $args = array_merge(array( '%%BLOG_URL%%' => get_option( 'siteurl' ), '%%HOME_URL%%' => get_option( 'home' ), '%%BLOG_NAME%%' => get_option( 'blogname' ), '%%BLOG_DESCRIPTION%%' => get_option( 'blogdescription' ), '%%ADMIN_EMAIL%%' => get_option( 'admin_email' ), '%%DATE%%' => date_i18n( get_option( 'date_format' ) ), '%%TIME%%' => date_i18n( get_option( 'time_format' ) ) ),$args); $to_replace = apply_filters( 'emailtpl/placeholders', $args);
3. on that same file, find send_email & send_email_postman functions and add this:
$placeholders = array("%%USER_EMAIL%%" => $args["to"]);
and pass it to the replace_placeholders function.
now you should be able to put “%%USER_EMAIL%% anywhere in the template and get the current addressee’s email address, so the unsubscribe link will relate to the current user.