I had a similar requirement, and wanted some form of moderation so just hacked up the following.
Basically it changes the post status to ‘pending’ for new topics and replies. It would be nice if the Topics and Replies menu options showed a little count bubble for Pending items (like Comments), but I couldn’t find a supported way to add that.
As an admin just edit the pending topic/reply and publish for it to appear.
If I have some time I see if I can make this a plugin to honour the Comment and BBPress comment and anon posting options etc.
Comments and improvements welcome
Add the following to your theme’s functions.php file.
class bbPressModeration {
function __construct() {
add_filter('bbp_new_topic_pre_insert', array($this, 'pre_insert'));
add_filter('bbp_new_reply_pre_insert', array($this, 'pre_insert'));
add_filter('bbp_has_topics_query', array($this, 'query'));
add_filter('bbp_has_replies_query', array($this, 'query'));
add_filter('bbp_get_topic_permalink', array($this, 'permalink'), 10, 2);
add_filter('bbp_get_reply_permalink', array($this, 'permalink'), 10, 2);
add_filter('bbp_get_topic_title', array($this, 'title'));
add_filter('bbp_get_reply_content', array($this, 'content'));
add_filter('bbp_current_user_can_publish_replies', array($this, 'can_reply'));
}
// Mark all new topics and replies as 'pending'
function pre_insert($data) {
global $wpdb;
// Check if user already published unless anonymous (post_author = 0)
$sql = $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_author = %d AND post_author <> 0 AND post_type IN ('topic','reply') AND post_status = 'publish'", $data['post_author']);
$count = $wpdb->get_var($sql);
if (!$count) {
// Anon or User never published topic/reply so mark as pending.
// Maybe notify admin ?
$data['post_status'] = 'pending';
}
return $data;
}
// Include pending topics and replies in the query
function query($bbp) {
if (!bbp_is_query_name( 'bbp_widget' )) {
$bbp['post_status'] .= ',pending';
}
return $bbp;
}
// Trash the permalink for pending topics/replies
// Would be nice if there was no link at all.
function permalink($permalink, $topic_id) {
global $post;
if ($post && $post->post_status == 'pending') {
return '#';
}
return $permalink;
}
// Alter pending topic title
function title($title) {
global $post;
if ($post && $post->post_status == 'pending') return $title . ' ' . __('(Awaiting moderation)', 'bbpress');
return $title;
}
// Hide content for pending replies
function content($content) {
global $post;
if ($post && $post->post_status == 'pending') return __('(Awaiting moderation)', 'bbpress');
return $content;
}
// Check if newly created topic is published and
// disable replies until it is.
function can_reply($retval) {
if (!$retval) return $retval;
return ('publish' == bbp_get_topic_status());
}
}
$bbpressmoderation = new bbPressModeration();
Ian