Created
August 22, 2015 20:20
-
-
Save bappi-d-great/81133871af98d5e5a7dd to your computer and use it in GitHub Desktop.
Protect only BuddyPress members page, not the profile page using WPMU Membership 2
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 | |
add_action( 'template_redirect', 'check_members_dir' ); | |
function check_members_dir() { | |
$membership_id = 189; | |
$protected_content_url = 'http://localhost/wpms/protected-content/'; // Must need trailing slash | |
$member_page_url = 'http://localhost/wpms/members/'; | |
if( function_exists( 'bp_is_members_component' ) ) { | |
if( bp_is_members_component() ){ | |
if( ! ms_has_membership( $membership_id ) ){ | |
wp_redirect( $protected_content_url . '?redirect_to=' . urlencode( $member_page_url ) ); | |
die(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment