@bkypes
Try adding the below code to bp-custom.php if a logged out visitor tries to go to the activity page then they are redirected to login. For more info on bp-custom.php please see:
https://codex.buddypress.org/developer/customizing/bp-custom-php/
/* Prevent logged out users from accessing bp activity page */
function nonreg_visitor_redirect() {
global $bp;
if ( bp_is_activity_component() ) {
if(!is_user_logged_in()) { //just a visitor and not logged in
wp_redirect( get_option('siteurl') . '/wp-login.php' );
}
}
}
add_filter('get_header','nonreg_visitor_redirect',1);
@bphelp that works perfectly! Thanks so much!
@bkypes
You are welcome, glad I could help!
That’s working great. What if I want to restrict viewing all the member info (profile, groups, friends,…) as well as activity stream to non logged in users. What should I do? I want to make my network closed to non logged in visitors…
@designac
I submitted a plugin today to the repository that will do that. It has dashboard settings to exclude pages from protection but it is optional. So stay tuned!
@bphelp can you please link to the plugin? Thanks!
@synaptic
Still waiting for the plugin review before I move it over to the repo but until then you can get it here.
https://github.com/bphelp/private_community_for_bp_lite
@designac @synaptic
Just wondering if you could supply some feedback. You may want to download and install it again from the same link. I made some minor changes but it really doesn’t add anything more then what I had but they are using me as a test monkey I suppose with the wp plugin review panel. It works great on 4 different installations I have and I would appreciate your feedback. Keep in mind I intentionally did not block wordpress pages, just the BP ones, but you also have the option to unblock activity for instance. I may however make some changes depending on the feedback given.
Thanks!
@bp-help, I just installed the plugin on my site and it works pretty well! I would have done it sooner but we completely rebuilt our site and BP wasn’t working with the theme we’ve been using. I have a quick question for you though. Is it possible to reverse the plugin to leave all pages open and then enter only the pages that I want to block? Our site is an ecommerce site so I want to leave everything open and accessible except for the BuddyPress pages.
@bp-help
I’ve been messing around with the first bit of code and changing the:
if ( bp_is_activity_component() ) {
to
if ( bp_is_groups_component() ) {
or
if ( bp_is_members_component() ) {
and each time I try it, it crashes my site. Since it worked with the activity, I feel like the code has to be pretty close to working, I’m just not quite sure what the issue would be.
I did some more digging and found another one of your older solutions that works perfectly here: https://buddypress.org/support/topic/hiding-groups-activity-members-list-to-non-members/