Created
February 13, 2023 04:10
-
-
Save ipokkel/3ceffae7e7788302563db15914db99ef to your computer and use it in GitHub Desktop.
Redirect membr back to Addon Package purchased after checkout.
This file contains hidden or 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 | |
/** | |
* Redirect member back to Addon Packages page after checkout. | |
* | |
* 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_addon_package_confirmation_url( $url, $user_id, $level ) { | |
// Let's only do this if Addon Packages is active and a package id is passed. | |
if ( function_exists( 'pmproap_hasAccess' ) && isset( $_REQUEST['ap'] ) && ! empty( $_REQUEST['ap'] ) ) { | |
$ap = get_post( $_REQUEST['ap'] ); | |
if ( $ap ) { | |
$url = get_permalink( $ap->ID ); | |
} | |
} | |
return $url; | |
} | |
add_filter( 'pmpro_confirmation_url', 'my_pmpro_addon_package_confirmation_url', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This recipe works for on-site payment gateways and additional code may be required if you are using off-site payment gateways, e.g. Stripe Checkout, PayFast, Paystack, or CCBill.
If you are using an off-site gateway please also add the following recipe
https://gist.github.com/andrewlimaza/eddc8ba56dd89aee6b32dd85391271d8