Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Created June 2, 2020 16:26
Show Gist options
  • Save ronalfy/4b53cad68555e60682e8d08cd04cc589 to your computer and use it in GitHub Desktop.
Save ronalfy/4b53cad68555e60682e8d08cd04cc589 to your computer and use it in GitHub Desktop.
Paid Memberships Pro - Multisite Redirect
<?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