Try this:
Code:
// delete activationid
//$DB_site->query("DELETE FROM " . TABLE_PREFIX . "useractivation WHERE userid=$userinfo[userid] AND type=0");
// ###################################################################
// # WELCOME HACK
// ###################################################################
$username = $user['username'];
$userid = $user['userid'];
//$username = $_POST['username'];
// Process each one of the replacement vars
$vars = array(
'$bbtitle' => $vboptions['bbtitle'],
'$username' => $username,
'$email' => $email,
'$userid' => $userid
);
$pmoptions['regpmtext'] = $vboptions['regpmtext'];
$pmoptions['regpmtitle'] = $vboptions['regpmtitle'];
$pmoptions['regforum'] = $vboptions['regforum'];
// Now that we have the options, we need to process eaach of the
// vars we can use
foreach($vars AS $_key => $_value)
{
$pmoptions['regpmtext'] = str_replace($_key, $_value, $pmoptions['regpmtext']);
$pmoptions['regpmtitle'] = str_replace($_key, $_value, $pmoptions['regpmtitle']);
}
// ########## START THREAD CREATION ##########
$forumid = $pmoptions['regforum'];
$foruminfo = fetch_foruminfo($forumid);
$post[title] = $pmoptions['regpmtitle'];
$post[message] = $pmoptions['regpmtext'];
$post[poststarttime] = TIMENOW;
//$post[posthash] = md5($post[poststarttime] . $user['userid'] . $user['salt']);
//$post['emailupdate'] = 9999;
build_new_post('thread', $foruminfo, array(), 0, $post, $errors);
// ########## END THREAD CREATION ##########
// ########## START SEND PM TO USER ##########
$from_userid = 3;
$from_username = theacoustician;
$welcome_thread = $post['threadid']; //thread id of thread created above
$to_userid = $user['userid'];
$to_username = $user['username'];
$title = "Important information regarding your registration!";
$message = "Pending your full approval, we have created a thread for you. The thread is located here. This will be the only thread you can post in until an administrator approves your membership. If you have any questions that you'd rather not post, feel free to reply to this private message.";
$iconid = 0;
$signature=1; // 1 to show sig, 0 to hide it
$disablesmilies=1; // 1 to hide smilies, 0 to show them
// build touserarray
$tostring=array($to_userid => $to_username);
// store the message
$DB_site->query("INSERT INTO " . TABLE_PREFIX . "pmtext\n\t(fromuserid, fromusername, title, message, touserarray, iconid, dateline, showsignature, allowsmilie)\nVALUES\n\t($from_userid, '" . mysql_escape_string($from_username) . "', '". mysql_escape_string($title) ."', '". mysql_escape_string($message) ."', '" . addslashes(mysql_escape_string($tostring)) . "', $iconid, " . TIMENOW . ", $signature, $disablesmilies)");
// get the inserted private message id
$pmtextid = $DB_site->insert_id();
// send in receiving user's inbox
$DB_site->query("INSERT INTO " . TABLE_PREFIX . "pm (pmtextid, userid) VALUES ($pmtextid, $to_userid)");
// add to PM receiving user's total (with pm-popup)
$DB_site->shutdown_query("UPDATE " . TABLE_PREFIX . "user SET pmtotal=pmtotal+1, pmunread=pmunread+1, pmpopup=2 WHERE userid=$to_userid");
// ########## END SEND PM TO USER ##########
// ###################################################################
// # END WELCOME HACK
// ###################################################################
Note, I haven't tested it. But, I try to use the variables the native code is using. It was using $user, which I know will be fully defined.