Hide BP Components to Non Members Except Specific URL
-
I have successfully implemented the solution described in a closed thread https://buddypress.org/support/topic/hiding-groups-activity-members-list-to-non-members/ about how to hide BP components to non logged in users. The code is below and it works great. What I am looking to do is to make an exception for a single, specific member URL that will be accessible to all users.
In summary:
1. Hide all BP components to non logged in users [achieved]
2. All non logged in users to see mysite.com/members/member-xThis is the code used for the first part in. Any help would be greatly appreciated.
/* Prevent logged out users from accessing bp components */
function nonreg_visitor_redirect() {
global $bp;
if ( bp_is_activity_component() || bp_is_groups_component() || bp_is_members_component() ) {
if(!is_user_logged_in()) { //just a visitor and not logged in
wp_redirect( get_option(‘siteurl’) . ‘/register’ );
}
}
}
add_filter(‘get_header’,’nonreg_visitor_redirect’,1);?>
WP version 4.8.0
BP version 2.12.12
- You must be logged in to reply to this topic.