Okay, I think I've figured part of it out. It doesn't seem that the code is grabbing the actual $bbuserinfo['userid']. Sometimes its null.
Any chance you could take a look at all the code for me? As it actually does a couple of things. Thanks.
(Sorry its kind of a mess, I cant really write my own code, so I've pieced together other peoples code to make this.)
This is my register.php (with an extra line of actual vB code on either end, so that you know where I stuck it)
PHP Code:
// delete activationid
//$DB_site->query("DELETE FROM " . TABLE_PREFIX . "useractivation WHERE userid=$userinfo[userid] AND type=0");
// ###################################################################
// # WELCOME HACK
// ###################################################################
$username = $bbuserinfo['username'];
//$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] . $bbuserinfo['userid'] . $bbuserinfo['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 = $bbuserinfo['userid'];
$to_username = $bbuserinfo['username'];
$title = "Important information regarding your registration!";
$message = "Pending your full approval, we have created a thread for you. The thread is located [url=http://uselessforums.com/showthread.php?t=" . $welcome_thread . "]here[/url]. 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
// ###################################################################
if ($userinfo['coppauser'] OR ($vboptions['moderatenewmembers'] AND !$userinfo['posts']))