Forked from ipokkel/pmpro-addon-package-confirmation-url.php
Created
November 27, 2024 12:18
-
-
Save JarrydLong/860d5a07b2d3ed79e9718a0c2bc48f65 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