Forked from eighty20results/pmpro-buddypress-membership-protection.php
Created
March 17, 2017 19:51
-
-
Save greathmaster/6ca80c4628ac47b330459117bc5c2984 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 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 <thomas@eighty20results.com> | |
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