Skip to:
Content
Pages
Categories
Search
Top
Bottom

Disable Member page to non-logged in users


  • welshlamb10
    Participant

    @welshlamb10

    Hi BuddyPress,

    I want to keep my site as private as possible.
    I would like to disable access to non-logged in users to the members directory or any other profile related pages. If they do try to access then they get re-directed to homepage.

    Please could you send me the php I need to add to my functions.php to achieve this??

    Many Thanks

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

  • shanebp
    Moderator

    @shanebp


    ajuuls
    Participant

    @ajuuls

    The plugin works fine. But there’s no option to hide the text “Members” when not signed in. It only redirects the user. That’s not really a good solution. Or am i totally wrong?


    Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    Please try this solution: https://wordpress.org/plugins/lock-my-bp/

    Thanks


    ajuuls
    Participant

    @ajuuls

    It works great. Thank you Prashant Singh. Fast answer aswell!

    However, do you know how i can change the text? I need it to another language. I can change some of the text but not text in the form? Any suggestions?


    Prashant Singh
    Participant

    @prashantvatsh

    You can use this plugin https://wordpress.org/plugins/loco-translate/ to translate/change the text.

    If it is a single text please let me know, I will provide a code snippet for that then there will be no need to install a plugin for just one text change.


    ajuuls
    Participant

    @ajuuls

    It’s working pretty good! Thanks for everything. I do still have some other small problems. If you can fix it, you’re my hero today! (even thou you already are now. Shhh..)

    This is my post:

    How to hide the “Home” tab under Profile (member navigation items)


    Prashant Singh
    Participant

    @prashantvatsh

    Thanks for the appreciation 🙂

    Please check my reply there.


    VVCARES
    Participant

    @maniekandan55gmailcom

    Just a simple snippet.

    //Hide for non-logged-in users (public visitors)
     function bp_logged_out_page_template_redirect() { 
       if( ! is_user_logged_in() && is_page( 'members' )|| is_page( 'activity' ) || bp_is_user() ) { 
          wp_redirect( home_url( '/register/' ) ); 
          exit(); 
       } 
     } add_action( 'template_redirect', 'bp_logged_out_page_template_redirect' );

    The snippet will do:
    IF the user is not logged-in..
    AND the page name is ‘members’ OR ‘activity’ OR bp-profile-page..
    THEN it will redirect to REGISTER page.


    fabianski
    Participant

    @fabianski

    this works, but only if the url of the page has only MEMBERS, if there is the username MEMBERS / USER does not work.
    Is there any way to solve this?


    sofoort
    Participant

    @sofoort

    //Hide for non-logged-in users (public visitors)
    function bp_logged_out_page_template_redirect() {
    if( ! is_user_logged_in() && is_page( ‘members’ )|| is_page( ‘activity’ ) || bp_is_user() ) {
    wp_redirect( home_url( ‘/register/’ ) );
    exit();
    }
    } add_action( ‘template_redirect’, ‘bp_logged_out_page_template_redirect’ );

    This code works, but now I can’t see the profile page. Every time I try I’ll get redirected to the register page. Even when I am logged in.

    Can someone help me solve this?


    silsbyc
    Participant

    @silsbyc

    sofoort,

    Try adding another pair of parenthesis to the if statement

    if( ! is_user_logged_in() && (is_page( ‘members’ )|| is_page( ‘activity’ ) || bp_is_user()) )

    Full code:

    //Hide for non-logged-in users (public visitors)
    function bp_logged_out_page_template_redirect() {
    if( ! is_user_logged_in() && (is_page( 'members' )|| is_page( 'activity' ) || bp_is_user()) ) {
    wp_redirect( home_url( '/register/' ) );
    exit();
    }
    } add_action( 'template_redirect', 'bp_logged_out_page_template_redirect' );

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