Created
May 18, 2022 10:14
-
-
Save ipokkel/4ddfeae5f4a4cfbbd6950bb5997ed046 to your computer and use it in GitHub Desktop.
Restrict and redirect non-members away from the BuddyPress activity or BuddyBoss news feed page.
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 | |
/** | |
* Restrict and redirect non-members away from the BuddyPress activity page (news-feed). | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_buddypress_activity_page_redirect() { | |
if ( defined( 'PMPRO_VERSION' ) && ! pmpro_hasMembershipLevel() && bp_is_active( 'activity' ) && is_page( bp_core_get_directory_page_id( 'activity' ) ) ) { | |
global $pmpro_pages; | |
$url = ! empty( $pmpro_pages['pmprobp_restricted'] ) ? pmpro_url( 'pmprobp_restricted' ) : pmpro_url( 'levels' ); | |
wp_safe_redirect( $url ); | |
exit; | |
} | |
} | |
add_action( 'template_redirect', 'my_pmpro_buddypress_activity_page_redirect' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment