Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Created October 8, 2020 09:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ipokkel/de8eead251310cb0ad9db343f009888d to your computer and use it in GitHub Desktop.
Save ipokkel/de8eead251310cb0ad9db343f009888d to your computer and use it in GitHub Desktop.
Redirect certain levels to a custom confirmation page after checkout.
<?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