PHP Code:
<?php
// Create a new thread
chdir('/var/www/vhosts/example.net.au/subdomains/smb/httpdocs/forum');
require_once('./global.php');
require_once('./includes/class_dm.php');
require_once('./includes/class_dm_threadpost.php');
require_once('./includes/functions_databuild.php'); // required for "build_forum_counters"
$threadsdm = new vB_DataManager_Thread_FirstPost($vbulletin, ERRTYPE_STANDARD);
$forumid = '3';
$userid = '2';
$title = 'Test New Thread';
$pagetext = 'This works... Whoo Hoo!!';
$allow_smilie = '1';
$visible = '1';
//$foruminfo = fetch_foruminfo($forumid); // Not sure what this does so removed it
//$threadsdm->set_info('forum', $foruminfo); // Not sure what this does so removed it
//$threadsdm->set('forumid', $foruminfo['forumid']); // Not sure what this does so removed it
$threadsdm->set('forumid', $forumid);
$threadsdm->set('userid', $userid);
$threadsdm->set('title', $title);
$threadsdm->set('pagetext', $pagetext);
$threadsdm->set('allowsmilie', $allow_smilie);
$threadsdm->set('visible', $visible); // not required?
// no 'post_userid'
// no 'posttext'
// no 'username'
$threadsdm->save();
build_forum_counters($forumid);
unset($threadsdm);
?>
--------------- Added [DATE]1210893914[/DATE] at [TIME]1210893914[/TIME] ---------------
Quote:
Originally Posted by Dismounted
What is your problem? It looks like you've got it down.
|
My previous code seemed to just not work... I was banging my head against a wall. Eventually I ended up with the code posted above - which seems to work (a New thread is created and the forums counters are updated).
If anyone has suggestions on improving my script please comment.