@djbnotts – sorry, missed your reply the other day. Your welcome. Just thought i’d suggest it as users seeing errors is a serious problem.
BP Private community does the exact same thing as David’s code (his code is their ‘default’ mode, and their optional method can be easily done easily just by removing the Exclamation mark just before the conditional).
Private community doesn’t seem to be maintained anymore (last update was in 2010) so you might be better off using that code as it’s slightly more recent and works in current version of 1.6 bleeding.