Last active
October 23, 2023 09:58
-
-
Save ipokkel/a73a0bca3a71b4ea282bf376c42dc985 to your computer and use it in GitHub Desktop.
Redirect members after PMPro checkout to the set level homepage instead of the default confirmation page. #pmpro #confirmation #redirect #homepages
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 redirect members after checkout to the set level homepage. | |
* | |
* This Requires PMPro Member Homepages installed and active. | |
* https://www.paidmembershipspro.com/add-ons/member-homepages/ | |
* | |
* If a homepage for a membership level is set this will | |
* redirect members after checkout to the set level homepage instead of | |
* the default 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_per_member_homepages( $rurl, $user_id, $pmpro_level ) { | |
// bail if necessary | |
if ( ! function_exists( 'pmpromh_getHomepageForLevel' ) ) { | |
return $url; | |
} | |
$level = pmpro_getMembershipLevelForUser( $user_id ); | |
$member_homepage_id = pmpromh_getHomepageForLevel( $level->id ); | |
if ( ! empty( $member_homepage_id ) ) { | |
$rurl = get_permalink( $member_homepage_id ); | |
} | |
return $rurl; | |
} | |
add_filter( 'pmpro_confirmation_url', 'my_pmpro_confirmation_url_per_member_homepages', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment