Skip to content

Instantly share code, notes, and snippets.

@dparker1005
Last active August 27, 2020 08:14
Show Gist options
  • Select an option

  • Save dparker1005/6a09ba2ff5d3307012b6e58833814f01 to your computer and use it in GitHub Desktop.

Select an option

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.
<?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