Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenkabuto/84420f6be12cf9ea61303045128e857f to your computer and use it in GitHub Desktop.
Save tenkabuto/84420f6be12cf9ea61303045128e857f to your computer and use it in GitHub Desktop.
Redirect away from the checkout page if you don't have a required level with Paid Memberships Pro.
/*
Redirect away from the checkout page if you don't have a required level.
*/
function my_template_redirect_upgrade()
{
global $pmpro_pages, $pmpro_level;
if(empty($pmpro_pages))
return;
if(is_page($pmpro_pages['checkout']) && $pmpro_level->id == 2 && !pmpro_hasMembershipLevel(1)) //change ids checked here
{
wp_redirect(site_url('page-explaining-you-need-level-1-first')); //change 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