Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)

  • zoewsaldana
    Participant

    @zoewsaldana

    Fixed it!! Okay, for anyone who encounters this issue, the problem was that for some reason (I think perhaps how WP or my server is caching pages) the hooks I was choosing to target for the behavior weren’t working. So instead I added both functions to the “wp” hook, and now it works site-wide!

    
    /* You can add custom functions below, in the empty area
    =========================================================== */
    
    function bp_guest_redirect( $name ) {
        if( ! is_user_logged_in() ) {
            if ( bp_is_activity_component() || bp_is_groups_component() || bp_is_blogs_component() || bp_is_directory() || bp_is_user() || bp_is_members_component() ) 
                wp_redirect( get_option('siteurl') . '/new_member/' );
        }
    }
    add_action( 'wp', 'bp_guest_redirect', 1, 1 );
    function bpfr_hide_rss_feed_to_nonreg_visitor() {
     if ( !is_user_logged_in() ) { 	
       remove_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
       remove_action( 'bp_actions', 'bp_activity_action_personal_feed' );
       remove_action( 'bp_actions', 'bp_activity_action_friends_feed' );
       remove_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
       remove_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
       remove_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
       remove_action( 'groups_action_group_feed', 'groups_action_group_feed' ); 
        }
    }
    add_action('wp', 'bpfr_hide_rss_feed_to_nonreg_visitor'); 
    
    

    My theme framework (WPZoom) also recommended I place theme modifying code in the functions/user/ pathway, so I modified functions.php there instead of using bp-custom. I think it would work either place, however.

    Thank you!


    zoewsaldana
    Participant

    @zoewsaldana

    Thank you all for the help!

    Okay, here’s the bizarre thing — I created a new user account and logged out to test its functionality. After I did this, I got the new_member redirect page exactly ONE TIME for every single BP page. So one time, it would prevent non-logged-in me from accessing Recent Activity, but if I tried again, it would work from here on out. I think there must be something going on with respect to how often the function is being called, and perhaps how my server is cacheing sites. Should I try placing a function call somewhere else, like in the theme or somewhere that is likely to be checked every refresh? Thank you!

    Zoƫ


    zoewsaldana
    Participant

    @zoewsaldana

    I attempted to use another similar solution I discovered on a recent thread (not 4 years old this time :-p) and still no luck. Here is that piece combined with the RSS backdoor protection:


    <?php
    function bp_guest_redirect( $name ) {

    if( ! is_user_logged_in() ) {

    if ( bp_is_activity_component() || bp_is_groups_component() || bp_is_blogs_component() || bp_is_directory() || bp_is_user() || bp_is_members_component() )
    wp_redirect( get_option('siteurl') . '/wp-login.php/' );

    }

    }
    add_action( 'get_header', 'bp_guest_redirect', 1, 1 );

    function bpfr_hide_rss_feed_to_nonreg_visitor() {

    if ( !is_user_logged_in() ) {

    remove_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
    remove_action( 'bp_actions', 'bp_activity_action_personal_feed' );
    remove_action( 'bp_actions', 'bp_activity_action_friends_feed' );
    remove_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
    remove_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
    remove_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
    remove_action( 'groups_action_group_feed', 'groups_action_group_feed' );
    }
    }
    add_action('init', 'bpfr_hide_rss_feed_to_nonreg_visitor');

    ?>


    zoewsaldana
    Participant

    @zoewsaldana

    Thanks for the reply! So weirdly, this worked for a very brief moment when I tried to open a group page — but then it stopped redirecting. Member profiles continue to show no matter what. I wonder if there’s some kind of server config thing going on…

Viewing 4 replies - 1 through 4 (of 4 total)
Skip to toolbar