WordPress

bp-custom.php

How to supress member list from non-logged in users.

 

The steps I took:

a) create a php file (bp-custom.php) in the plugin folder in this way.

wp-content / plugins / bp-custom.php

b) inside it, do this:

<?php
// hacks and mods will go here

/* Prevent logged out users from accessing bp activity page */
function nonreg_visitor_redirect() {
global $bp;
if ( bp_is_activity_component() || bp_is_groups_component() || bp_is_group_forum() || bp_is_page( BP_MEMBERS_SLUG ) ) {
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);
?>

c) that is all.

Source: https://buddypress.org/support/topic/hiding-groups-activity-members-list-to-non-members/