Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Extending the Private Forums Plugin

I finally made a custom “private forum” (note the single noun) plugin:

define('FORO_STAFF', 22);

add_filter('get_posts_where', 'ryuuko_staff_where_posts');
function ryuuko_staff_where_posts($where) {
if (!bb_is_user_logged_in() || !bb_current_user_can('moderate')) {
//var_dump($where);
$where .= " AND p.forum_id <> '" . FORO_STAFF . "' ";

}
return $where;
}

add_filter('get_topics_where', 'ryuuko_staff_where_topics');
function ryuuko_staff_where_topics($where) {
if (!bb_is_user_logged_in() || !bb_current_user_can('moderate')) {
$where .= " AND t.forum_id <> '" . FORO_STAFF . "' ";
}
return $where;
}

add_filter('get_forums', 'ryuuko_staff_forums');
function ryuuko_staff_forums($forums) {
if (!bb_is_user_logged_in() || !bb_current_user_can('moderate')) {
$where .= " AND t.forum_id <> '" . FORO_STAFF . "' ";
$forum_key = -1;
foreach ($forums as $key => $forum)
if (intval($forum->forum_id) == FORO_STAFF) {
$forum_key = $key;
break;
}
unset($forums[$key]);
}
return $forums;
}

add_action('bb_forum.php_pre_db', 'ryuuko_forum_redirect');
function ryuuko_forum_redirect($forum_id) {
if (!bb_is_user_logged_in() || !bb_current_user_can('moderate')) {
if ($forum_id == FORO_STAFF) bb_die("No puedes ver esto!");
}
}

Maybe it’s useful for someone. The constant FORO STAFF is the id for the private forum. In this case, only users with the ‘moderate’ capability can see the forum.

Skip to toolbar