PDA

View Full Version : Building a new thread problem


Dean C
07-25-2005, 11:19 AM
$forumid = 26;
$foruminfo = fetch_foruminfo(forumid);
$newpost = array(
'emailupdate' => 9999,
'userid' => 8,
'username' => 'Botty',
'title' => 'Application from : ' . $vbulletin->GPC['username']
);
eval('$newpost[message] = "' . fetch_template('APPLY_post') . '";');
require_once(DIR . '/includes/functions_newpost.php');
build_new_post('thread', $foruminfo, array(), array(), $newpost, $errors);


That script, when logged in, posts it using my username, not the specified bots name. Why is this happening?

EDIT:


// make post
$forumid = 26;
$foruminfo = fetch_foruminfo($forumid);
$newpost = array(
'emailupdate' => 9999,
'userid' => 8,
'username' => 'VouchBot',
'title' => 'Application from : ' . $vbulletin->GPC['username']
);
eval('$newpost[message] = "' . fetch_template('APPLY_post') . '";');
require_once(DIR . '/includes/functions_newpost.php');
$olduserid = $vbulletin->userinfo['userid'];
$vbulletin->userinfo['userid'] = 8;
build_new_post('thread', $foruminfo, array(), array(), $newpost, $errors);
$vbulletin->userinfo['userid'] = $olduserid;


This fixes the problem within the postbit, but the lastposter info is incorrect.

mtha
09-10-2005, 08:14 PM
$forumid = 26;
$foruminfo = fetch_foruminfo(forumid);
$newpost = array(
'emailupdate' => 9999,
'userid' => 8,
'username' => 'Botty',
'title' => 'Application from : ' . $vbulletin->GPC['username']
);
eval('$newpost[message] = "' . fetch_template('APPLY_post') . '";');
require_once(DIR . '/includes/functions_newpost.php');
build_new_post('thread', $foruminfo, array(), array(), $newpost, $errors);


That script, when logged in, posts it using my username, not the specified bots name. Why is this happening?

EDIT:


// make post
$forumid = 26;
$foruminfo = fetch_foruminfo($forumid);
$newpost = array(
'emailupdate' => 9999,
'userid' => 8,
'username' => 'VouchBot',
'title' => 'Application from : ' . $vbulletin->GPC['username']
);
eval('$newpost[message] = "' . fetch_template('APPLY_post') . '";');
require_once(DIR . '/includes/functions_newpost.php');
$olduserid = $vbulletin->userinfo['userid'];
$vbulletin->userinfo['userid'] = 8;
build_new_post('thread', $foruminfo, array(), array(), $newpost, $errors);
$vbulletin->userinfo['userid'] = $olduserid;


This fixes the problem within the postbit, but the lastposter info is incorrect.

was you able to fix the "Lastposter" problem?

I also want to introduce other lastposter value into the field, but havent got any success yet.

Paul M
09-10-2005, 08:27 PM
You also need to set

$vbulletin->userinfo['username'] = "Botname";

before calling the build post function.

Andreas
09-10-2005, 08:27 PM
You have to overwrite the whole $vbulletin->userinfo array, or avoid using build_new_post()

mtha
09-10-2005, 08:51 PM
I got mine worked out with postusername to show what I want.

build_new_post will call
class_dm_threadpost.php and function verify_userid(&$userid)
this function will set

if ($return == true)
{
if (isset($this->validfields['username']))
{
$this->do_set('username', $this->info['user']['username']);
}
else if (isset($this->validfields['postusername']))
{
$this->do_set('postusername', $this->info['user']['username']);
}
}

I try to use a custom field for postusername -> just need to replace it with

if ($return == true)
{
if (isset($this->validfields['username']))
{
$this->do_set('username', $this->info['user']['field10']);
}
else if (isset($this->validfields['postusername']))
{
$this->do_set('postusername', $this->info['user']['field10']);
}
}