Created
September 3, 2016 14:11
-
-
Save eighty20results/117e55037df2031dd1e0efdf9d2c04dd to your computer and use it in GitHub Desktop.
Limit access to BuddyPress components for users without a valid Paid Memberships Pro 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 | |
/* | |
Plugin Name: PMPro/BuddyPress members only access | |
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/ | |
Description: Limit access to BuddyPress pages/components for non-members. | |
Version: .1 | |
Author: Thomas Sjolshagen @ Stranger Studios <[email protected]> | |
Author URI: http://www.eighty20results.com/thomas-sjolshagen | |
*/ | |
function pmpro_buddypress_restrict_page_access() { | |
global $pmpro_pages; | |
global $bp; | |
if ( bp_is_activity_component() || | |
bp_is_groups_component() /*|| bbp_is_single_forum()*/ || | |
bp_is_forums_component() || | |
bp_is_blogs_component() || | |
bp_is_page( BP_MEMBERS_SLUG ) ) { | |
if( false == pmpro_hasMembershipLevel() ) { | |
// send to the levels page if the user doesn't have a valid membership | |
wp_redirect( get_permalink( $pmpro_pages['levels'] ) ); | |
} | |
} | |
} | |
add_filter('get_header','pmpro_buddypress_restrict_page_access', 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment