Forked from strangerstudios/my_template_redirect_upgrade.php
Last active
March 11, 2016 03:02
-
-
Save greathmaster/dd4fe4a29d0f643b44fb to your computer and use it in GitHub Desktop.
Redirect away from the level page if you don't have a required level with Paid Memberships Pro.
This file contains 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
/* | |
Redirect away from the level page if you don't have membership | |
*/ | |
function my_template_redirect_upgrade() | |
{ | |
global $pmpro_pages, $pmpro_level; | |
if(empty($pmpro_pages)) | |
return; | |
$member_level = pmpro_getMembershipLevelForUser(); | |
if(is_page($pmpro_pages['levels']) && pmpro_hasMembershipLevel() && !pmpro_isLevelExpiringSoon($member_level->ID)) | |
{ | |
wp_redirect(site_url()); //change redirect url here | |
exit; | |
} | |
} | |
add_action('template_redirect', 'my_template_redirect_upgrade'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment