Friday, September 19, 2014

hidden forums 404 with bbpress

BBpress allows private forums. I configured a private forum and the default behavior was undesirable: if you are not logged in, visiting a link to the forum returns the generic 404 page.

I was happy with the 404 page, but I wanted some special when people visited the private forum - that encouraged them to register or login.

I hacked this into my 404.php:


...




 
  if ('/forums/forum/someforum/' == $_SERVER['REQUEST_URI']) {
        _e('You need to be registered and logged in to participate in the forum.');
        } else { 
        _e( 'It looks like nothing was found at this location. Maybe try a search', 'twentyfourteen' ); echo '
'; get_search_form();
  } ?>

                        
...


Sadly, this blog publishing software doesn't do syntax highlighting, so good luck.