<?php
function restricted_content_filter( $content ) {
if ( !current_user_can( 'administrator' ) && is_content_restricted() ) {
$content = 'Restricted!';
}
return $content;
}
add_filter( 'the_content', 'restricted_content_filter' );
add_filter( 'the_excerpt', 'restricted_content_filter' );
function is_content_restricted() {
global $post;
$restricted_posts = array( 1, 2, 3, 4, 5 ); //You'll want a UI to set this in the options table
if ( in_array( $post->ID, $restricted_posts ) ) {
$user = get_current_user();
$mode = 'live'; //You'll want to set this to live or test... and store that setting in the options table to set and get it dynamically.
$status = get_user_meta( '_member_status_' . $mode, true );
if ( 'active' === $status ) {
return false;
} else {
return true;
}
}
}