I'm trying to create posts. And I'm very new to xenforo...

fly

Well-known member
I found an old thread that says pretty much how to do it here. However I'm assuming there are some includes or something required to actually make that code work enclosed in a standalone php script. Can someone explain what the full code might look like?

PHP:
$writer = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
$writer->set('user_id', <userid of the poster>);
$writer->set('username', <username of the poster>);
$writer->set('node_id', <id of the node the thread is in>);
$writer->set('title', <thread title>);
$writer->set('prefix_id', <id of the thread prefix, if any>);
$postWriter = $writer->getFirstMessageDw();
$postWriter->set('message', <thread contents>);

$writer->save();//Thread is saved.
 
Top Bottom