Creating Threads with the DataWriter

R

ragtek

Guest
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
Take a look at library/XenForo/Model/Counters.php - from what I see this model is responsible for the statistics. :)
 

Kier

XenForo developer
Staff member
Create a thread then wait a few minutes for the rebuild to be scheduled.
 
R

ragtek

Guest
It is updated by the cron entry "Rebuild Board Totals Counter"
thx.

took some time but now they are up2date

So i don't need to add something to my code.

First "real Add-on" finished.
*strike*
 
Top