Skip to content

Instantly share code, notes, and snippets.

@finalwebsites
Created December 31, 2024 15:17
Show Gist options
  • Save finalwebsites/b9695acd8fc4c3e103aa370ba2031dae to your computer and use it in GitHub Desktop.
Save finalwebsites/b9695acd8fc4c3e103aa370ba2031dae to your computer and use it in GitHub Desktop.
Send WordPress emails with a template created in Maileroo
<?php
// replace the template ID 123 with your own
add_filter('ssbm_add_template_data', function($payload, $atts) {
if ($atts['message'] == strip_tags($payload['html'])) {
$message = nl2br($atts['message']);
unset($payload['html']);
$payload['template_id'] = 123;
$payload['template_data'] = json_encode(
array('content' => $message)
);
}
return $payload;
}, 10, 2);
@finalwebsites
Copy link
Author

This WordPress filter hook can be used to send your plain text emails in WordPress, with a stylish HTML template created in Maileroo.
To use this hook you need to install the Maileroo WordPress plugin first.
Copy this code snippet into the functions.php file from your child theme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment