Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Created March 9, 2016 17:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strangerstudios/9a125089ffe7eef2f34f to your computer and use it in GitHub Desktop.
Save strangerstudios/9a125089ffe7eef2f34f to your computer and use it in GitHub Desktop.
Run PMPro shortcodes later to avoid issues with the_content filters/etc
/*
Run PMPro shortcodes later to avoid issues with the_content filters/etc
Add this code to your active theme's functions.php or a custom plugin.
You may need to change the priority of the add_filter calls below to get the desired result.
*/
//this function removes the shortcodes to keep them from being messed with
function pmpro_shortcodes_later_prep($content) {
$shortcodes = array('pmpro_account', 'pmpro_billing', 'pmpro_cancel', 'pmpro_checkout', 'pmpro_confirmation', 'pmpro_invoice', 'pmpro_levels');
foreach($shortcodes as $shortcode) {
$content = str_replace("[" . $shortcode . "]", "<!-- PMPROSHORTCODEREPLACE " . $shortcode . " PMPROSHORTCODEREPLACE -->", $content);
}
return $content;
}
add_filter('the_content', 'pmpro_shortcodes_later_prep', 1);
//this function adds the shortcodes back in later
function pmpro_shortcodes_later_restore($content) {
$shortcodes = array('pmpro_account', 'pmpro_billing', 'pmpro_cancel', 'pmpro_checkout', 'pmpro_confirmation', 'pmpro_invoice', 'pmpro_levels');
foreach($shortcodes as $shortcode) {
$content = str_replace("<!-- PMPROSHORTCODEREPLACE " . $shortcode . " PMPROSHORTCODEREPLACE -->", do_shortcode("[" . $shortcode . "]"), $content);
}
return $content;
}
add_filter('the_content', 'pmpro_shortcodes_later_restore', 100);
@laurenhagan0306
Copy link

This recipe is included in the blog post on "Filter Members Only Content Later (for Page Builders and Certain Plugin Conflicts)" at Paid Memberships Pro here: https://www.paidmembershipspro.com/filter-members-only-content-later-for-page-builders-and/

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