Here's the deal, I have it set so when a new ticket is created it sends a notification to all support staff based on usergroup perms, the problem is it won't send and as far as I know it isn't pulling data to send the email.
Here is the code:
PHP Code:
// Notify Support Staff
$ids = '';
// Gather all usergroup information
$usergroups = $vbulletin->db->query_read("SELECT * FROM `" . TABLE_PREFIX . "usergroup`");
while ($usergroup = $vbulletin->db->fetch_array($usergroups))
{
// only use if the usergroups are support staff or admin
if ($usergroup['usergroupid'] == '6' OR $issupport)
{
$ids .= ',' . $usergroup['usergroupid'];
}
}
// of course if not empty then continue
if (!empty($ids))
{
// gather information on all users that are in the usergroups that are set as staff
$users = $vbulletin->db->query_read("
SELECT userid, username
FROM `" . TABLE_PREFIX . "user`
WHERE usergroupid IN (0$ids)
ORDER BY username
");
while ($user = $vbulletin->db->fetch_array($users))
{
// self explanatory I hope
$supportstaff[$user['userid']] = array
(
'userid' => $user['userid'],
'username' => $user['username']
);
}
}
// assign variables which I'm not sure are even working
$userids = $supportstaff['userid'];
$tostaff = fetch_userinfo($userids);
$toemail = $tostaff['email'];
$subject = $vbulletin->options['bbtitle'] ." New Ticket Created";
$message = "A new ticket has been created. Please visit the link below to view the ticket.<br />Ticket: ".$vbulletin->options['bburl']."/".$support_file."?do=ticket&id=".$ticketid."";
vbmail($toemail, $subject, $message, $headers);
Keep in mind everything you see in there is for testing purposes only, once I have it working I plan to make phrases and such to use in the emails.
Anyway, I have been trying a few things to get this working, any help would be much appreciated.