Last active
August 27, 2020 08:14
-
-
Save dparker1005/6a09ba2ff5d3307012b6e58833814f01 to your computer and use it in GitHub Desktop.
Restricts all posts for CPT campaign. Only users with a level can view regardless of what is set in the "Require Membership" box.
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 | |
| // Copy from below here... | |
| /* | |
| * Restricts all posts for CPT campaign. Only users with a level can view | |
| * regardless of what is set in the "Require Membership" box. | |
| * | |
| * Can change 'campaign' on line 12 to any CPT. | |
| */ | |
| function my_pmpro_has_membership_access_filter( $hasaccess, $post ) { | |
| if ( 'campaign' != $post->post_type || false === $hasaccess ) { | |
| return $hasaccess; | |
| } | |
| return pmpro_hasMembershipLevel(); | |
| } | |
| add_filter( 'pmpro_has_membership_access_filter', 'my_pmpro_has_membership_access_filter', 5, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment