Forked from strangerstudios/my_pmpro_term_template_redirect.php
Last active
April 21, 2020 07:22
-
-
Save femiyb/d3f831f9c06261e8f22051f45cff54ad 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('PGreen-blog', 'content_type', $post) && 351 == $post->ID && !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