Created
February 26, 2020 16:15
-
-
Save ronalfy/444cc2acdf6256e9e7964ede42aff031 to your computer and use it in GitHub Desktop.
Paid Memberships Pro Archive Redirect Based on Member Level
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_archive_redirect() { | |
$levels_to_check = array( | |
1, | |
2, | |
3, | |
); | |
if ( ( is_tax() || is_archive() || is_search() ) && function_exists( 'pmpro_hasMembershipLevel' ) ) { | |
if ( ! pmpro_hasMembershipLevel( $levels_to_check ) ) { | |
wp_redirect( pmpro_url( 'levels' ) ); | |
exit; | |
} | |
} | |
} | |
add_action( 'template_redirect', 'pmpro_archive_redirect' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment