Created
October 12, 2015 21:16
-
-
Save strangerstudios/be666d7681118b30b875 to your computer and use it in GitHub Desktop.
Redirect non-members away from CPTs with specific term
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 | |
function my_pmpro_term_template_redirect() { | |
global $post; | |
//change category and level ID here | |
if( has_term('my_category', 'category', $post) && !pmpro_hasMembershipLevel()) { | |
wp_redirect(pmpro_url('levels')); | |
exit; | |
} | |
} | |
add_action('template_redirect', 'my_pmpro_term_template_redirect'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This recipe is included in the blog post on "Restrict Access by Membership Level for Custom Post Type (CPT) Categories" at Paid Memberships Pro here: https://www.paidmembershipspro.com/restrict-access-by-membership-level-for-custom-post-type-cpt-categories/