One of my products auto-creates a thread, and here is the code that actually handles creating the thread:
PHP Code:
// Create the report thread.
// Temporarily override the maximum characters that can be included in a post.
$maxchars = $vbulletin->options['postmaxchars'];
$vbulletin->options['postmaxchars'] = 0;
$mthread =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$reportforuminfo = fetch_foruminfo($mforumid);
$reportthreadinfo = array();
$mpostip = "";
$mallowsmilie = '1';
$mvisible = 1;
$showsig = 1;
$mthread->set_info('forum', $reportforuminfo);
$mthread->set_info('thread', $reportthreadinfo);
$mthread->set_info('skip_floodcheck', true);
$mthread->setr('forumid', $mforumid);
$mthread->setr('userid', $muserid );
$mthread->setr('pagetext', $report);
if ($vbulletin->options['markfl_report_prefixes_enabled'])
{
$mthread->set('prefixid', 'reportthread_unsolved');
}
$mthread->setr('title', $title);
$mthread->set('allowsmilie', $mallowsmilie);
$mthread->set('visible', $mvisible);
$mthread->set('ipaddress', $mpostip);
$mthread->set('showsignature', $showsig);
$mthread->pre_save();
if (count($mthread->errors) < 1)
{
$threadid = $mthread->save();
unset($mthread);
build_thread_counters($mthread);
}
else
{
print "Error making new thread! " . $mthread->errors[0] . $mthread->errors[1] . $mthread->errors[2] ;
}
build_forum_counters($forumid);
//Restore setting for maximum characters allowed in posts.
$vbulletin->options['postmaxchars'] = $maxchars;