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 MaryOJob/7c9301b557523f2ff93e9a827629b91a to your computer and use it in GitHub Desktop.
Save MaryOJob/7c9301b557523f2ff93e9a827629b91a to your computer and use it in GitHub Desktop.
Limit Post Views: Don't allow post views for certain categories.
<?php
/**
* Limit Post Views: Don't allow post views for certain categories.
*/
function my_pmprolpv_has_membership_access( $has_access, $post ) {
// Set blocked categories here.
$blocked_categories = array( 'silver', 'gold' );
foreach( $blocked_categories as $category ) {
if( has_category( $category, $post ) ) {
$has_access = false;
}
}
return $has_access;
}
add_filter( 'pmprolpv_has_membership_access', 'my_pmprolpv_has_membership_access', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment