Forked from strangerstudios/my_pmpro_confirmation_redirect.php
Created
August 1, 2017 07:52
-
-
Save sonipb/6719e5c90c1f1eeb10d9645057167455 to your computer and use it in GitHub Desktop.
Redirect Paid Memberships Pro Confirmation to Another Page Based on Level
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
/* | |
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"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment