public function addAnswer($content, $author_id, $follow = false, $resolved = false, $private = false)
 {
     $user = get_userdata($author_id);
     if (empty($author_id) or empty($user)) {
         throw new Exception(CMA::__('Invalid user.'));
     }
     if (!$this->isVisible()) {
         throw new Exception(CMA::__('You have no permission to post this answer.'));
     }
     $content = self::contentFilter($content, $author_id);
     if (empty($content)) {
         $errors[] = __('Content cannot be empty', 'cm-answers-pro');
     }
     if (($badWord = CMA_BadWords::filterIfEnabled($content)) !== false) {
         $errors[] = sprintf(CMA_Labels::getLocalized('msg_content_includes_bad_word'), $badWord);
     }
     if (!empty($errors)) {
         throw new Exception(serialize($errors));
     }
     $approved = CMA_Settings::getOption(CMA_Settings::OPTION_ANSWER_AUTO_APPROVE) || self::isAuthorAutoApproved($author_id) ? 1 : 0;
     $answer = new CMA_Answer(array('comment_post_ID' => $this->getId(), 'comment_author' => $user->display_name, 'comment_author_email' => $user->user_email, 'comment_author_IP' => $_SERVER['REMOTE_ADDR'], 'user_id' => $author_id, 'comment_parent' => 0, 'comment_content' => apply_filters('comment_text', str_replace(';)', ':)', $content)), 'comment_approved' => $approved, 'comment_date' => current_time('mysql'), 'comment_type' => CMA_Answer::COMMENT_TYPE));
     do_action('cma_answer_post_before', $this, $answer);
     $answer->save();
     $answerId = $answer->getId();
     if (!$answerId) {
         throw new Exception('Failed to add answer.');
     }
     $attachmentsIds = CMA_AnswerAttachment::handleUpload($this->getId());
     if (!empty($_POST['attached']) && is_array($_POST['attached'])) {
         $attachmentsIds = array_merge($attachmentsIds, $_POST['attached']);
     }
     foreach ($attachmentsIds as $attachmentId) {
         $answer->addAttachment($attachmentId);
     }
     $answer->setPrivate($private);
     if (!$private) {
         $this->updateThreadMetadata(array('commentId' => $answerId, 'authorId' => $author_id, 'follow' => $follow, 'resolved' => $resolved, 'approved' => $approved, 'answerId' => $answerId), $notifyUsers = !$private);
         if ($approved) {
             $this->setUpdated();
         }
     }
     if ($approved) {
         self::updateQA($author_id);
         $this->notifyAboutNewAnswer($answerId);
     } else {
         if (!$approved) {
             wp_notify_moderator($answerId);
         }
     }
     if (CMA_Settings::getOption(CMA_Settings::OPTION_LOGS_ENABLED)) {
         CMA_AnswerPostLog::instance()->log($answerId);
     }
     do_action('cma_answer_post_after', $this, $answer);
     return $answerId;
 }