Skip to:
Content
Pages
Categories
Search
Top
Bottom

Disable Member page to non-logged in users


  • welsh10
    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 18 replies - 1 through 18 (of 18 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.


    Anonymous User 11014282
    Inactive

    @anonymized-11014282

    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.


    Anonymous User 16833488
    Inactive

    @anonymized-16833488

    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' );


    metalhead
    Participant

    @aaronthomas1979

    All 3 of these options (BP Simple Private, Buddypress Lock, or the custom code) all cause significant page speed issues. (like 3 seconds)

    Any suggestions to combat the privacy issue without compromising speed?


    spokendesigns
    Participant

    @spokendesigns

    The custom code worked! Thank you.


    saintavel
    Participant

    @saintavel

    Thanks silsbyc it’s working for me your snippet


    epgb101
    Participant

    @epgb101

    Hello
    When I install that plugin (https://wordpress.org/plugins/lock-my-bp/) it works perfectly – except now, my existing buddypress registration and login (with custom signup questions) is now replaced by what looks like standard WP Login/Register fields.

    Q: how can I disable keep my original Login/Register signup page/fields?
    (I cannot see any shortcodes in my exiating BuddyPress register page to enter in lock-my-bp ‘Custom Form’ field – it’s blank)

    The page I need help with: https://www.101christianchat.com/members/


    Varun Dubey
    Participant

    @vapvarun

    @epgb101 you can test https://wordpress.org/plugins/buddy-registration-widget/ it offers a shortcode for the register page, which can be used in plugin settings.

    In our next update, we are going to provide options to map any custom page to display restricted content which will give you better content over the content.


    skpc1
    Participant

    @skpc1

    How to hiding members page from non logged in users ?

    //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( 'https://vvcares.com/?buddypressBlogPostRedirect' ) ); exit(); } } add_action( 'template_redirect', 'bp_logged_out_page_template_redirect' );

    Ref; https://vvcares.com/blog/post/wordpress-buddypress-hide-page-from-non-members


    Oscar Allford
    Participant

    @oskarallford

    Hi!!

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