Skip to:
Content
Pages
Categories
Search
Top
Bottom

Requiring Login to Access Community and getting error message correct

  • Avatar of IndieConnect
    IndieConnect
    Member

    @indieconnect

    We have a membership site. I got BuddyPress installed and functional. Now I would like to protect the community by requiring that someone log in before accessing any of the BuddyPress features. Working with WishList Member tech support I was advised to use these lines of code in each of the BP Template Pack files listed in step 3 of the setup.
    1) “

    before this `

    `
    and after this `

    `

    2) “

    3) ` `

    4) ` `

    The file buddypress-protect.php contains the following code:
    `

    You must be logged in to view this content. :)

    `

    So, the good news is that the community is protected, but the bad news is that the error message is not showing up. I get a page that shows a header and footer, but the rest is blank. I searched the internet trying to learn more about “include templatepath” and an obtuse post briefly mentioned that this will not work with BuddyPress. Is this true and is there a better way to do this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Avatar of IndieConnect
    IndieConnect
    Member

    @indieconnect

    Oh my – did you get any of the code? How could I screw that up?

    Avatar of @mercime
    @mercime
    Keymaster

    @mercime

    @indieconnect surround code with backticks ( ` ) the symbol between the parentheses, not apostrophes :-)

    Avatar of IndieConnect
    IndieConnect
    Member

    @indieconnect

    Just shoot me. Is this a backtick ` ? I thought it was dust on my keyboard – lol…

    Avatar of IndieConnect
    IndieConnect
    Member

    @indieconnect

    Well, I went back and read the obtuse post again. If I understood it correctly, when you are using a child theme, which I am, instead of line 3 above I should use line 3 below.

    I changed line 3 above to:

    I switched it out of all 15 files and it seems to not work either.

    Any thoughts?

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    Not sure why you are calling another file simply to echo out one sentence? could you not simply do the:
    `else:

    You must be logged in to view this content

    endif;`

    Better still why not run a re-direct from your functions.php file something like:

    `
    function lock_bp_pages() {
    if( bp_is_register_page() || bp_is_activation_page() || bp_is_page(BP_GROUPS_SLUG) || is_front_page() || bp_is_blog_page())
    return; // we want to allow access to these pages so we call a halt to the function progressing.

    // if the above pages are not being accessed then we do a general re-direct to a WP page where we can add any content we fancy
    if( ! is_user_logged_in() )
    bp_core_redirect( $bp->root_domain .’/call-to-action/’ );

    }

    add_action( ‘bp_init’, ‘lock_bp_pages’ );`

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

You must be logged in to reply to this topic.