Forked from messica/my_pmprolpv_has_membership_access.php
Created
October 12, 2023 13:41
-
-
Save MaryOJob/7c9301b557523f2ff93e9a827629b91a 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