Created
August 6, 2018 08:13
-
-
Save andrewlimaza/df4ff6e00886a748a62865b4aa2b241d to your computer and use it in GitHub Desktop.
redirect user away from the page if they do not have a specific membership level.
This file contains 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 | |
/** | |
* This will redirect members with level 1 from site.com/page-slug to the home page. | |
* Please adjust accordingly and add to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function redirect_member_from_page_x() { | |
if ( is_page( 'page-slug' ) && pmpro_hasMembershipLevel( 1 ) ) { | |
wp_redirect( home_url() ); //redirect to home page. Change home_url() to home_url( '/page-slug' ) to redirect to specific page. | |
exit; | |
} | |
} | |
add_action( 'template_redirect', 'redirect_member_from_page_x' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment