I'm not an PHP expert but I tried to code an autodelete function for users that have never posted and are 1 month inactive. I took the delete user code from, \qa-include\db\users.php
Added the code below at the end of file, \qa-include\db\users.php
Can some one help me out with the code I came up with, but is obviously not working.
/**
* Delete inactive users from the database, along with everything they have ever done (to the extent that it's possible)
* @param $userid
*/
$result = qa_db_read_all_values(qa_db_query_sub('SELECT userid FROM ^users WHERE loggedin < '.(now() - interval 1 month).' AND written = NULL'));
while ($userid = qa_db_read_all_values($result))
{
qa_db_query_sub('UPDATE ^posts SET lastuserid=NULL WHERE lastuserid=$', $userid);
qa_db_query_sub('DELETE FROM ^userpoints WHERE userid=$', $userid);
qa_db_query_sub('DELETE FROM ^blobs WHERE blobid=(SELECT avatarblobid FROM ^users WHERE userid=$)', $userid);
qa_db_query_sub('DELETE FROM ^users WHERE userid=$', $userid);
// All the queries below should be superfluous due to foreign key constraints, but just in case the user switched to MyISAM.
// Note also that private messages to/from that user are kept since we don't have all the keys we need to delete efficiently.
qa_db_query_sub('UPDATE ^posts SET userid=NULL WHERE userid=$', $userid);
qa_db_query_sub('DELETE FROM ^userlogins WHERE userid=$', $userid);
qa_db_query_sub('DELETE FROM ^userprofile WHERE userid=$', $userid);
qa_db_query_sub('DELETE FROM ^userfavorites WHERE userid=$ OR entitytype=$ AND entityid=$', $userid, QA_ENTITY_USER, $userid);
qa_db_query_sub('DELETE FROM ^userevents WHERE userid=$', $userid);
qa_db_query_sub('DELETE FROM ^uservotes WHERE userid=$', $userid);
qa_db_query_sub('DELETE FROM ^userlimits WHERE userid=$', $userid);
}