public function handle_insert($value, Falcon_Reply $reply)
{
if (!empty($value)) {
return $value;
}
$post = get_post($reply->post);
if (!$this->is_allowed_type($post->post_type)) {
return $value;
}
$user = $reply->get_user();
if ($reply->is_valid()) {
Falcon::notify_invalid($user, bbp_get_topic_title($reply->post));
return false;
}
$new_reply = array('post_parent' => $reply->post, 'post_author' => $user->ID, 'post_content' => $reply->parse_body(), 'post_title' => $reply->subject);
$meta = array('author_ip' => '127.0.0.1', 'forum_id' => bbp_get_topic_forum_id($reply->post), 'topic_id' => $reply->post);
$reply_id = bbp_insert_reply($new_reply, $meta);
do_action('bbp_new_reply', $reply_id, $meta['topic_id'], $meta['forum_id'], false, $new_reply['post_author']);
// bbPress removes the user's subscription because bbp_update_reply() is hooked to 'bbp_new_reply' and it checks for $_POST['bbp_topic_subscription']
bbp_add_user_subscription($new_reply['post_author'], $meta['topic_id']);
return $reply_id;
}