Skip to:
Content
Pages
Categories
Search
Top
Bottom

Members page open for non logged in users


  • Carsten Lund
    Participant

    @carsten-lund

    This might be a general WP issue, but it of special concern for members privacy in BP.

    Members is not part of the BP components, I wonder why that is?

    So BuddyPress instead create a members page, permalink: domain/members, where the BP Content are custom links. Why is that?

    The problem is that visitors not logged in can enter domain/members, and see the members. they can’t view any of the profiles, but they can se a list of members. This is not very conveniant for members privacy.

    How can I block this?

    Regards
    Carsten

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

  • billysgtr
    Participant

    @billysgtr

    Hey,
    you can add this in functions.php

    $not_logged_in_user = '';
    function prevent_subscriber_from_members() {
        global $not_logged_in_user;
        if (
            // Look for  /members/ page
            stripos($_SERVER['REQUEST_URI'],'/members/') !== false
            ) {         
            // If subscriber, redirect on home page
            if (!is_user_logged_in() ) {              
                if ($not_logged_in_user == '') { $not_logged_in_user = get_option('home'); }            
                // Send a temporary redirect
                wp_redirect($not_logged_in_user,302);            
            }           
        }       
    }
    add_action('init','prevent_subscriber_from_members',0);

    It checks if the user is logged in. If not, redirects him to home page


    Carsten Lund
    Participant

    @carsten-lund

    Hi, and thank you very much for the code, it works very well. Can I, in an easy way ad the blog page to the code, or should I just copy the code and change ‘members’ with ‘blog’?

    I wonder why this code is not part of the build in security in WP and BP, so anyone just can ad a /members /blogs and so on, and see content for logged in users only. i guess you can’t do that in Facebook.


    billysgtr
    Participant

    @billysgtr

    You can do the same thing for any page you want 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar