I’m trying to configure forums using the bbpress plugin that can only be viewed by logged in users. I attempted creating them as private but found that sub-forums don’t show up on my root /forums page. Another forum suggested using is_user_logged_in() to determine whether or not forums are displayed.
What is the best place to put a check for is_user_logged_in() that will hide all forum related pages and posts from non-logged in users. I am up for other suggestions as well if there is a better way to do it, but I am not finding much documentation.
The solution I went with was to create a file in my theme’s folder named bbpress.php. I then copied the contents of my theme’s page.php file into the new file and modified it to only show it’s contents when a user is logged in. In my case it looked like the following:
Apparently the bbpress plugin looks in a a particular order for the template it will use (see http://bbpress.org/forums/topic/where-do-i-choose-a-custom-template-for-the-bbpress-20-plugin). I chose to name the file bbpress.php since it makes it clear when I look back at my code what the file is connected to.
The only way I’ve gotten around this so far is using version 2.1 from the trac site and setting things up so the top-level forums are categories instead of forums, ie:
Set the members forums and top level category to “hidden”, and use the Members plugin to allow whatever other user levels besides admin permission to view hidden forums.
Any other variation I’ve tried gives the same results you indicated, and this fix doesn’t seem to work in 2.0 due to a bug in setting the visibility on forums. Requires some further testing once 2.1 is officially released, but it’s working for me so far.