The PM data manager seems to completely kill the page when I use this function. It just does a white page and no PM is sent.
PHP Code:
function ushop_send_pm($title, $text, $user, $from=0) {
global $vbulletin;
// require the class
require_once(DIR . '/includes/class_dm_pm.php');
// Who's the PM from?
if ($from == 0 OR $from['userid'] == $vbulletin->userinfo['userid']) {
$from = $vbulletin->userinfo;
} elseif ($from == "default") {
$from = fetch_userinfo($vbulletin->options['ushop_pmfrom']);
} else {
$from = fetch_userinfo($from['userid']);
}
// Who are we sending this PM to?
if (isset($user[0]['userid'])) {
// Sending to multiple.
foreach ($user as $omguser) {
$toarray[] = $omguser['username'];
}
$to = implode(";", $toarray);
} else {
// Sending to one.
$to = $user['username'];
}
// create the DM to do error checking and insert the new PM
$pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
$pmdm->set('fromuserid', $from['userid']);
$pmdm->set('fromusername', $from['username']);
$pmdm->set('title', $title);
$pmdm->set('message', $text);
$pmdm->set_recipients($to, $from['permissions']);
$pmdm->set('dateline', TIMENOW);
// If no errors, save.
if ($pmdm->errors) {
return $pmdm->errors;
}
$pmdm->save();
}
I have since went back to using my old function which got the job done. I'll probably
try fixing the version of the function that uses the data manager, but for now...