Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Created February 26, 2020 16:15
Show Gist options
  • Save ronalfy/444cc2acdf6256e9e7964ede42aff031 to your computer and use it in GitHub Desktop.
Save ronalfy/444cc2acdf6256e9e7964ede42aff031 to your computer and use it in GitHub Desktop.
Paid Memberships Pro Archive Redirect Based on Member Level
<?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