Theme authors and developers often ask how to modify a membership email or plugin-generated page. Most templates can be adjusted using Action and Filter Hooks, custom stylesheet/CSS, and the email templates settings page.

Some customizations can only be achieved through a completely custom template. This article explains how to use the pmpro_loadTemplate() function to load any of the plugin-generated pages or system-generated emails from a different location.

Banner for Advanced Code Recipe Tutorial for Paid Memberships Pro

Overriding PMPro Page Templates

Paid Memberships Pro generates frontend page content via the shortcodes pmpro_account, pmpro_billing, pmpro_cancel, pmpro_checkout. pmpro_confirmation, pmpro_invoice, and pmpro_levels. If you cannot accomplish your customization needs via hooks and filters or a custom stylesheet/CSS and need finer control over the HTML code generated, then you might want to override the template files for these pages.

By default, Paid Memberships Pro will look in your active theme (and parent theme if applicable) for a directory named /paid-memberships-pro/pages. You can copy any file from /wp-content/plugins/paid-memberships-pro/pages/ folder into that theme location and tweak the files to your needs. PMPro will load your modified version of the template instead of the default one that is bundled with Paid Memberships Pro.

This way you can edit those files without breaking your changes when you upgrade Paid Memberships Pro later. There still made be additions or changes to our default templates that you will want to or need to change in your custom templates, but you’ll have less work to do than if you “hacked the core” PMPro plugin.

Read the full documentation on using custom PMPro page templates »

Loading Custom Page Templates From a Plugin Instead of Your Theme

PMPro uses the pmpro_pages_custom_template_path filter hook to check a specific directory for ALL page templates. If the template is found, it will be used. If it’s not found, PMPro will next look in the theme. If the theme does not include custom templates, the default plugin templates will be loaded.

To keep adjustments outside of your theme folder, create a plugin for PMPro Customizations and add a folder named /templates/. Then add code to your pmpro-customizations.php plugin file to tell PMPro to load these templates like this:

Creating Your Own Page Templates

If you are loading a template in a plugin of your own, you could be using the PHP require() or include() functions. You could also use the WordPress get_template_part() function.

If you are a developer building an extension for PMPro you can support the same method we offer to allow users to override your template by placing their own version in the /paid-memberships-pro/pages/ directory of their theme or filtering the template location in a custom plugin. The correct function to use to load your template is pmpro_loadTemplate(). Here is an example that you can use to load your template file. We’ll be updating our Add Ons to work the same way.

Customizing Member Emails

Every email that could possibly be sent through your Membership site can be adjusted to fit your needs. Read through the full list of system-generated emails to see all the possible emails that your membership site offers.

While our preferred way to edit these emails is through the Memberships > Settings > Email Templates page in the WordPress admin, you can also use the same methods described above for plugin or theme-loaded templates.

Loading Custom Email Templates From a Plugin Instead of Your Theme

Sometimes you need to programatically update email templates. Similar to filtering page templates, you can use the pmpro_email_custom_template_path filter like this:

You can also create your own email templates and load them using pmpro_loadTemplate(‘name’, NULL, ’email’); which will try to load email templates from /wp-content/themes/your-theme/paid-memberships-pro/email/name.html.

Note that we use “email” without an S for our email folder but “pages” with an S for the pages folder.

We’re going to be adding some extra helper functionality around creating new email templates so users can easily override the email templates your Add Ons use. When we get that done, we’ll post to the blog here. In the meantime, we can help in the member forums.

Free Course: Membership Site Development—The Basics

Develop a deeper understanding of membership site development in this beginner-level course. Learn how to make your site work better, save yourself time and money, and improve your site's performance.

Featured Image for Membership Site Development Course: The Basics
Was this article helpful?
YesNo