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

Creating Threads with the DataWriter

R

ragtek

Guest
#1
I'm using this code to create a thread:
PHP:
$writer = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
        $writer->set('user_id', $visitor['user_id']);
        $writer->set('username', $visitor['username']);
        $writer->set('title', $input['subject']);
                $postWriter = $writer->getFirstMessageDw();
        $postWriter->set('message', $input['message']);

        $writer->set('node_id', $forumId);
                $writer->preSave();
                $writer->save();
                $thread = $writer->getMergedData();
                  return $this->responseRedirect(
                XenForo_ControllerResponse_Redirect::SUCCESS,
                $this->getDynamicRedirect(),
                new XenForo_Phrase('your_message_has_been_sent')
            );
It's working nice, but it doesn't update the Forum Statistics.
What's missing here?
 

Attachments

dmnkhhn

Active member
#2
Take a look at library/XenForo/Model/Counters.php - from what I see this model is responsible for the statistics. :)