Re: Making Member/Group Lists Require Log-In
I didn’t have a bp-custom.php file in either the plugins or mu-plugins folders so I created one from scratch.
You did the right thing. It does not exist unless you create it!
I uploaded it to the wp-content/plugins directory.
(I also tried wp-content/mu-plugins directory.)
I went to log in and see if I needed to activate it – nothing shows up on the screen period – even on the dashboard.
The file bp-custom.php needs to be placed in /plugins/. You cannot activate it. It automatically is loaded by bp-core.php as the first required file if it exists in that location.
As far as the code to put in bp-custom.php, try something like this:
<?php
function restrict_access(){
global $bp, $bp_unfiltered_uri;
if (!is_user_logged_in() &&
($bp_unfiltered_uri[0] == BP_MEMBERS_SLUG ||
$bp_unfiltered_uri[0] == BP_GROUPS_SLUG))
{
bp_core_redirect( get_option('home') . "/register" );
}
}
add_action( 'wp', 'restrict_access', 3 );
?>