Forked from andrewlimaza/redirect-member-away-from-page.php
Last active
February 6, 2020 08:49
-
-
Save femiyb/6adb96fa310c29183a48485f57d01ad4 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 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 | |
/** | |
* 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( 'shop' ) && ! pmpro_hasMembershipLevel() ) { | |
wp_redirect( home_url('login') ); //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