Skip to content

Instantly share code, notes, and snippets.

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 kimcoleman/8d52cc293b1ea5e33b6957d5873b7154 to your computer and use it in GitHub Desktop.
Save kimcoleman/8d52cc293b1ea5e33b6957d5873b7154 to your computer and use it in GitHub Desktop.
Show a unique message on content restricted for a hidden membership level.
<?php
/**
* Show a unique message on content restricted for a hidden membership level.
*
*/
function hidden_level_content_pmpro_text_filter( $text ) {
global $post;
$access = pmpro_has_membership_access( $post->ID, NULL, true );
$level_ids = $access[1];
if ( is_array( $level_ids ) && in_array( 9, $level_ids ) ) {
$text = '<p>The respective Membership Level was currently inactive.</p>';
}
return $text;
}
add_filter( 'pmpro_non_member_text_filter', 'hidden_level_content_pmpro_text_filter', 5);
add_filter( 'pmpro_not_logged_in_text_filter', 'hidden_level_content_pmpro_text_filter', 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment