Created
April 2, 2019 09:04
-
-
Save femiyb/29f8dda0a440a7fba1ffa88cfd78c300 to your computer and use it in GitHub Desktop.
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 | |
/* | |
* Redirects members-only content to the restricted access page if a user is logged out or not a member. | |
*/ | |
function redirect_non_member() { | |
$okay_pages = array(pmpro_getOption('billing_page_id'), pmpro_getOption('account_page_id'), pmpro_getOption('levels_page_id'), pmpro_getOption('checkout_page_id'), pmpro_getOption('confirmation_page_id')); | |
if ( ! pmpro_has_membership_access() && ! is_front_page() && ! is_page( $okay_pages ) ) { | |
wp_redirect( site_url ( '/access-restricted/' ) ); | |
exit; | |
} | |
} | |
add_action( 'template_redirect', 'redirect_non_member' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment