Created
October 8, 2020 09:42
-
-
Save ipokkel/de8eead251310cb0ad9db343f009888d to your computer and use it in GitHub Desktop.
Redirect certain levels to a custom confirmation page after checkout.
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
<?php | |
/** | |
* This recipe will allow you to send predefined Membership Levels to a unique confirmation page. | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_confirmation_url( $url, $user_id, $level ) { | |
$level_id = intval( $level->id ); | |
$redirect_levels = array( 1, 3 ); // level ID's of membership levels to redirect to custom confirmation page. | |
if ( in_array( $level_id, $redirect_levels, false ) ) { | |
$url = home_url( '/my-page-slug/' ); //change this to the url you want to redirect to | |
} | |
return $url; | |
} | |
add_filter( 'pmpro_confirmation_url', 'my_pmpro_confirmation_url', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment