• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Manipulate discussion_state in new created discussions


Well-known member
In some occasions I want to manipulate the message state of new added discussions. In DataWriter_Discussion_Thread everything useful for that is protected. In ControllerPublic_Forum::actionAddThread, the discussion_state is set:
    // discussion state changes instead of first message state
     $writer->set('discussion_state', $this->getModelFromCache('XenForo_Model_Post')->getPostInsertMessageState(array(), $forum));
This works, but how could I get access to the $writer variable again?
class Spam_ControllerPublic_Forum extends XFCP_Spam_ControllerPublic_Forum
   public function actionAddThread()
     $response = parent::actionAddThread();
     $threadId = $writer->get['thread_id'];
     $writer = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
     $writer->set('discussion_state', 'moderated');

     return $response;
If its not possible to get access to $writer, how could I get access to the redirecting URL?
      $return = XenForo_Link::buildPublicLink('threads', $thread);

     return $this->responseRedirect(
       new XenForo_Phrase('your_thread_has_been_posted')