Skip to content

Instantly share code, notes, and snippets.

@messica
Created April 25, 2019 16:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save messica/d9e7c5747de36b65301fe17507f1f720 to your computer and use it in GitHub Desktop.
Save messica/d9e7c5747de36b65301fe17507f1f720 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