Last active
June 9, 2020 13:37
-
-
Save andrewlimaza/f61f97989cdac363d041777072db56d2 to your computer and use it in GitHub Desktop.
Redirect non-members to 'Content Restricted' BuddyPress page for normal content.
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 | |
/** | |
* Redirect non-members away from 'normal' content to BuddyPress content restricted page. | |
* Requires the BuddyPress Integration to be installed - https://www.paidmembershipspro.com/add-ons/buddypress-integration/ | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_template_redirect_require_membership_access() { | |
if ( ! pmpro_has_membership_access() && ! bp_current_component() && ! is_archive() && ! is_home() && function_exists( 'pmpro_bp_redirect_to_access_required_page' ) ) { | |
pmpro_bp_redirect_to_access_required_page(); | |
} | |
} | |
add_action( 'template_redirect', 'my_template_redirect_require_membership_access' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment