I have looked through the source code quite a bit (particularly in the includes/email-lib.php file), but am struggling to find out how I might override the path for the default email template in a plugin. It seems pretty straightforward for a theme, but we want to bundle a default email template with one of our plugins. For much of your plugins there are actions and filters for everything which we have loved, but not seeing how it might be possible here. Any ideas?
Brian Hanna
Hi Brian,
It isn’t currently possible for the e-mail template to be over-ridden by a plugin. The plug-in current looks in three locations: the child theme (if it exists), the parent theme and the template directory in Event Organiser FES.
The only way to get round this is, is that there is a filter eventorganiser_template_{template-name}
(replace {template-name}
with the name of the template). This filters the entire e-mail body, so you could replace that with your own mark-up / e-mail template:
add_filter( 'eventorganiser_template_{...}', function( $body ) {
//Replace $body with the markup for the e-mail. e.g:
ob_start();
include( '/absolute/path/to/template.php' );
$body = ob_get_contents(); // assign buffer contents to variable
ob_end_clean(); // end buffer and remove buffer contents
return $body;
} );
Stephen Harris
Perfect, you are a rockstar – did exactly what I needed it to do. Thanks!
Brian Hanna