Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Last active January 8, 2020 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipokkel/cb6f7ab38270fc5dd23e757e736cdd76 to your computer and use it in GitHub Desktop.
Save ipokkel/cb6f7ab38270fc5dd23e757e736cdd76 to your computer and use it in GitHub Desktop.
Tell PMPro to filter the content a bit later (for users not in a specific role) to work with ProfitBuilder plugin #pmpro #profitbuilder #compatibility
<?php // do NOT copy this line, copy from below this line
/*
Tell PMPro to filter the_content a bit later.
This will sometimes fix issues where theme or plugin elements (e.g. videos)
are not being filtered by PMPro. Note that this sometimes will cause
some things (e.g. share links) to be filtered that you don't want to be
filtered... and sometimes edits to the theme or a child theme are
required to get the desired effect.
Add the below code to your custom plugin or Code Snippets Plugin by following this guide
https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
/* -- NOTE --
Profit Builder hooks into the_content at priority order 999
in profit_builder_class.php
on line 633 for v1.9.8
and line 1417 for v2.5.9
through applying this filter: add_filter('the_content', array(&$this, 'replace_content'), 999);
*/
function my_init_change_pmpro_content_filter_priority() {
$user = wp_get_current_user();
$allowed_roles = array('administrator'); // add or remove roles as required, e.g. 'administrator', 'editor'
if( !array_intersect($allowed_roles, $user->roles ) ) {
remove_filter('the_content', 'pmpro_membership_content_filter', 5);
add_filter('the_content', 'pmpro_membership_content_filter', 1000);
}
}
add_action('init', 'my_init_change_pmpro_content_filter_priority');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment