How to lock homepage in Buddypress Social theme for logged out users

Hi,

what I'm looking for is a quick way to remove every visibility of the inside of the community for visitors that are not subscribed.
Basically, if you don't login in the community, you should not be able to browse groups, forums, activities and such from the homepage. And no search too.

Is there a simple way to cut out all that from the homepage and leave only header, pic, login form and maybe also just the widget on the bottom?

I'm using WPMU 2.9.2, BP 1.2.1 and latest Buddypress Social theme.

Thank you!
Luke

  • Richie_KS

    do you mean you want all not logged-in user when visit your site even on home to redirect to
    either login page or register page right?

    just edit the check_if_privacy_on filter in bp-social/functions.php line 68
    - of coz you need to enable privacy in theme option for the privacy to work first.

    edit to:
    function check_if_privacy_on() {
    $privacy_enable = get_option('tn_buddysocial_privacy_status');
    if($privacy_enable == "enable") {
    global $bp;
    if(!is_user_logged_in()) {
    wp_redirect( get_option('siteurl') . '/' . BP_REGISTER_SLUG );
    }
    }
    }

    update here again if it didn't work ok

    cheers

  • Luke

    works perfectly, just one line added to check bp_is_blog_page(), otherwise it was kicking me off the main page as well


    function check_if_privacy_on() {
    $privacy_enable = get_option('tn_buddysocial_privacy_status');
    if($privacy_enable == "enable") {
    global $bp;
    if ( !bp_is_blog_page() ) {
    if(!is_user_logged_in()) {
    wp_redirect( get_option('siteurl') . '/wp-login.php' );
    }
    }
    }
    }

    Thank you so much, this really helped and solved my problem!

  • Richie_KS

    you're right..the first code will not redirect to register page..oops
    yep..you're final code should do it.
    or a more proper way like

    function check_if_privacy_on() {
    $privacy_enable = get_option('tn_buddysocial_privacy_status');
    if($privacy_enable == "enable") {
    global $bp;
    if ( !bp_is_register_page() && !bp_is_activation_page() ) {
    if(!is_user_logged_in()) {
    wp_redirect( get_option('siteurl') . '/' . BP_REGISTER_SLUG );
    }
    }
    }
    }

    cheers