How to add new variables to Paid Memberships Pro email templates

June 12, 2015

In a recent project I was looking to add new variables to the email templates add-on of the Paid Memberships Pro plugin for WordPress.

The variable I wanted to add was the site_url or home_url.

Add the following to your functions.php file of your them to add new email template variables:

//add new email template variables
add_filter("pmpro_email_filter", "my_pmpro_email_filter");
function my_pmpro_email_filter($email) {
    $extra_variables = array(
        'site_url' => site_url()	
    foreach($extra_variables as $key => $value) {
        $email->subject = str_replace("!!" . $key . "!!", $value, $email->subject);
        $email->body = str_replace("!!" . $key . "!!", $value, $email->body);
    return $email;

Just add whatever extra variables to the $extra_variables array.

Anthony Montalbano

If it's worth doing, it's worth doing right.

Published on: June 12, 2015

Last modified on: December 8, 2021