In answer to this question:
https://vborg.vbsupport.ru/showthread.php?t=292986
I think it might solve the problem if you add an intval() call to make sure the userid is a number, like:
Code:
$vbulletin->db->query_write("INSERT INTO " . TABLE_PREFIX . "logins (userid, username, ipaddress, phpdate, logintype) VALUES (" . intval($vbulletin->userinfo['userid']) . ", '" . $vbulletin->db->escape_string($vbulletin->userinfo['username']) . "', '" . $vbulletin->db->escape_string(IPADDRESS) . "', " . TIMENOW . ", 'FAILED ATTEMPT')");