foreach ($users AS &$user)
{
$userIdQuoted = $db->quote($user);
$db->delete('xf_user', "user_id = $userIdQuoted");
$db->delete('xf_user_field_value', "user_id = $userIdQuoted");
$db->delete('xf_user_group_relation', "user_id = $userIdQuoted");
$db->delete('xf_user_trophy', "user_id = $userIdQuoted");
$db->delete('xf_user_confirmation', "user_id = $userIdQuoted");
$db->delete('xf_user_external_auth', "user_id = $userIdQuoted");
$db->delete('xf_user_field_value', "user_id = $userIdQuoted");
$db->delete('xf_permission_entry', "user_id = $userIdQuoted");
$db->delete('xf_permission_entry_content', "user_id = $userIdQuoted");
if ($this->get('is_moderator'))
{
$db->delete('xf_moderator', "user_id = $userIdQuoted");
$db->delete('xf_moderator_content', "user_id = $userIdQuoted");
}
if ($this->get('is_admin'))
{
$db->delete('xf_admin', "user_id = $userIdQuoted");
$db->delete('xf_admin_permission_entry', "user_id = $userIdQuoted");
}
if ($this->get('is_banned'))
{
$db->delete('xf_user_ban', "user_id = $userIdQuoted");
}
$db->delete('xf_profile_post', "profile_user_id = $userIdQuoted");
$db->delete('xf_news_feed', "user_id = $userIdQuoted");
$db->delete('xf_user_news_feed_cache', "user_id = $userIdQuoted");
$db->delete('xf_user_alert', "alerted_user_id = $userIdQuoted");
$db->delete('xf_user_follow', "follow_user_id = $userIdQuoted");
$db->delete('xf_user_follow', "user_id = $userIdQuoted");
$db->delete('xf_conversation_user', "owner_user_id = $userIdQuoted");
// note: leaving records in conversation recipient to keep data somewhat intact for others
$db->delete('xf_ip', "content_type = 'user' AND user_id = $userIdQuoted");
// note: leaving content-associated IPs
$this->getModelFromCache('XenForo_Model_Avatar')->deleteAvatar($userId, false);
}