Created
January 8, 2021 11:53
-
-
Save ideadude/82fd7b1618885874af7b90cedfc2040d to your computer and use it in GitHub Desktop.
Redirect BuddyPress registration to the PMPro levels page.
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 BuddyPress registration to the PMPro levels page. | |
* Add this code into a Code Snippet or custom plugin. | |
* https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/ | |
* Note that this gist will redirect users to the level pages. | |
* You can adjust it to link to checkout for a specific level | |
* or, if you have only one level, adjust it to link to the | |
* checkout page, which will default to the first available level. | |
*/ | |
function my_redirect_buddypress_registration_to_pmpro_levels() { | |
global $post, $pmpro_pages; | |
//If BP or PMPro are not active, ignore | |
if( !function_exists( 'bp_is_register_page' ) || !function_exists( 'pmpro_url' ) ) { | |
return; | |
} | |
$bp_pages = get_option( 'bp-pages' ); | |
if( bp_is_register_page() && $post->ID != $pmpro_pages['levels'] ) | |
{ | |
$url = pmpro_url("levels"); | |
wp_redirect($url); | |
exit; | |
} | |
} | |
add_action( 'template_redirect', 'my_redirect_buddypress_registration_to_pmpro_levels', 75 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment