* Thread subscription mode set to "no email" (if it was previously set to instant, daily or weekly email)
* All their thread and forum subscriptions set to 'no email'.
* A PM to explain the above.
To do this, I replaced the code in your "Move Users To Bounce Usergroup" plugin with this:
Code:
$bounces = $vbulletin->db->query_read("
SELECT messageid, toemail
FROM " . TABLE_PREFIX . "sent_email
WHERE bounced = 1
");
if ($vbulletin->db->num_rows($bounces) > 0)
{
$toemails = array();
$messageids = array();
while ($bounce = $vbulletin->db->fetch_array($bounces))
{
$toemails[] = "'" . $bounce['toemail'] . "'";
$messageids[] = $bounce['messageid'];
}
$toemails = array_unique($toemails);
// start added code here... define data for PM data manager
$tonames = array();
$touids = array();
$fromuser = fetch_userinfo(1);
$message = "We tried to deliver an email to you, but unfortunately, it bounced. To prevent us sending more mail to you while your email provider is not accepting it, we have deactivated all the email-related features of your account. To reactivate your account, go to your UserCP, and update your email address. You will then get a confirmation email. Clicking on the link in this confirmation email should re-enable your account, at which point you will need to visit your UserCP options page to re-enable the email notifications you wish to use.";
$affected = $vbulletin->db->query_read("SELECT userid,username FROM " . TABLE_PREFIX . "user WHERE email IN (" . implode(', ', $toemails) . ")");
while ($affected = $vbulletin->db->fetch_array($affected)) {
$tonames[] = $affected['username'];
$touids[] = $affected['userid'];
}
$tonames = array_unique($tonames);
$pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_SILENT);
$pmdm->set('fromuserid', '1');
$pmdm->set('fromusername', 'EmailBot');
$pmdm->set_info('reciept', false);
$pmdm->set_info('savecopy', false);
$pmdm->set('title', 'Email Broken!');
$pmdm->set('message', $message);
$pmdm->set_recipients(implode(";",$tonames), $fromuser['permissions']);
$pmdm->set('dateline', TIMENOW);
$pmdm->save();
// this is stock mod code to move them to the different usergroup.
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET usergroupid = " . $vbulletin->options['bm_usergroup'] . ", membergroupids = '', displaygroupid = 0 WHERE usergroupid NOT IN (" . $vbulletin->options['bm_excludeusergroups'] . ") AND email IN (" . implode(', ', $toemails) . ")");
// and stock code to delete their message tracking info...
$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "sent_email WHERE messageid IN (" . implode(', ', $messageids) . ")");
// continue custom code to update their user options...
// stop them generating any more email!
// pm popup = YES
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET pmpopup = 1 WHERE email IN (" . implode(', ', $toemails) . ")");
// send notification email on PM - NO
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET options = (options - 4096) WHERE (options & 4096) AND email IN (" . implode(', ', $toemails) . ")");
// admin email OFF
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET options = (options - 16) WHERE (options & 16) AND email IN (" . implode(', ', $toemails) . ")");
// set autosubscribe = without email WHERE autosubscribe_with_email
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET autosubscribe = 1 WHERE (autosubscribe > 1) AND email IN (" . implode(', ', $toemails) . ")");
// set emailupdates = 0 for their thread subscriptions
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "subscribethread SET emailupdate = 0 WHERE (emailupdate > 0) AND userid IN (" . implode(', ', $touids) . ")");
// set emailupdates = 0 for their forum subscriptions
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "subscribeforum SET emailupdate = 0 WHERE (emailupdate > 0) AND userid IN (" . implode(', ', $touids) . ")");
// finish
unset($toemails, $messageids);
}
$vbulletin->db->free_result($bounces);