Created
June 2, 2020 16:26
-
-
Save ronalfy/4b53cad68555e60682e8d08cd04cc589 to your computer and use it in GitHub Desktop.
Paid Memberships Pro - Multisite Redirect
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 | |
function pmpro_multisite_subsite_custom_redirect() { | |
if ( is_main_site() || is_admin() ) { | |
return; | |
} | |
if ( function_exists( 'pmpro_hasMembershipLevel' ) ) { | |
global $current_user; | |
if ( 0 == $current_user->ID || ! pmpro_hasMembershipLevel() ) { | |
wp_redirect( get_site_url( 1, '/membership-account/membership-levels/' ) ); // Assume main site ID is 1. | |
exit; | |
} | |
} | |
} | |
add_action( 'template_redirect', 'pmpro_multisite_subsite_custom_redirect' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment