Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Last active July 6, 2021 20:16
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save strangerstudios/2706590 to your computer and use it in GitHub Desktop.
Save strangerstudios/2706590 to your computer and use it in GitHub Desktop.
Redirect Paid Memberships Pro Confirmation to Another Page Based on Level
/*
This code will redirect users from the default PMPro confirmation page to a specific page depending on their level.
Set the confirmation_pages array. Array keys should be membership level ids and the values are the page ids. So array(1=>2) will redirect membership level with id = 1 to the page with id = 2.
*/
function my_pmpro_confirmation_redirect()
{
$confirmation_pages = array(1 => 2); //change this use your membership level ids and page ids
global $pmpro_pages;
if(is_page($pmpro_pages['confirmation']))
{
foreach($confirmation_pages as $clevel => $cpage)
{
if(pmpro_hasMembershipLevel($clevel))
{
wp_redirect(get_permalink($cpage));
exit;
}
}
}
}
add_action("wp", "my_pmpro_confirmation_redirect");
@jmurphy444
Copy link

Where would one put this code...many of the other Gist's advise where to place.....

@strangerstudios
Copy link
Author

Same place. Put it in your active theme's functions.php or a custom plugin. Search for pmpro-customization for how to create a custom plugin.

@johndavis82
Copy link

How do you do this for more than one membership level? Do you just paste the code again and change the numbers to a new page ID and membership level?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment