Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Last active September 9, 2021 07:44
Show Gist options
  • Save andrewlimaza/e67dc3c00cb8a5c1b07b7d39caca2174 to your computer and use it in GitHub Desktop.
Save andrewlimaza/e67dc3c00cb8a5c1b07b7d39caca2174 to your computer and use it in GitHub Desktop.
Overwrite email templates inside Paid Memberships Pro by adding HTML templates to theme directory.
<?php
/**
* Overwrite email templates from child theme HTML templates.
* Create html templates in your child theme under paid-memberships-pro/email/
* Add this code to your site by following this guide -
*/
function cg_pmpro_load_from_theme_template( $body, $email ) {
if ( file_exists( get_stylesheet_directory() . '/paid-memberships-pro/email/' . $email->template . '.html' ) ) {
$body = file_get_contents( get_stylesheet_directory() . '/paid-memberships-pro/email/' . $email->template . '.html' );
}
return $body;
}
add_filter( 'pmpro_email_body', 'cg_pmpro_load_from_theme_template', 15, 2 );
@Clautrade
Copy link

Hello Andrew, thanks for this hook, anyway it cannot works ...
about $body need to get the content instead of the directory, it may be:

if ( file_exists( get_stylesheet_directory() . '/paid-memberships-pro/email/' . $email->template . '.html' ) ) {
        $direct = get_stylesheet_directory() . '/paid-memberships-pro/email/' . $email->template . '.html';
        $body = file_get_contents($direct);

This works. Thanks

@andrewlimaza
Copy link
Author

Thanks, I've updated the code. Sorry I missed that.

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