Skip to content

Instantly share code, notes, and snippets.

@ideadude
Created March 22, 2021 19:20
Show Gist options
  • Save ideadude/15c0955169eabdc414f8eee53405b661 to your computer and use it in GitHub Desktop.
Save ideadude/15c0955169eabdc414f8eee53405b661 to your computer and use it in GitHub Desktop.
Load your own templates for Paid Memberships Pro using a custom plugin.
/**
* Include this code in your custom WordPress plugin
* to load your own versions of the PMPro page templates.
* To override the cancel.php template, place your own
* cancel.php template in a folder like this:
* ../plugins/yourpluginslug/templates/cancel.php
*
* Using priority 100 will make sure this runs after
* other code using the smae hook. For example,
* it will run later than the Reason for Cancelling Add On
* which uses priority 99. :)
*/
function my_pmpro_page_templates( $templates, $page_name ) {
$templates[] = plugin_dir_path(__FILE__) . 'templates/' . $page_name . '.php';
return $templates;
}
add_filter( 'pmpro_pages_custom_template_path', 'my_pmpro_page_templates', 100, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment