Created
April 25, 2019 16:46
-
-
Save messica/d9e7c5747de36b65301fe17507f1f720 to your computer and use it in GitHub Desktop.
Limit Post Views: Don't allow post views for certain categories.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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