General developer forum

Help on deleting old users

 
Picture of Sven Niland
Help on deleting old users
 
Hello,

I'm hopeful someone here can provide me with some help on a method to delete lots of old users from a 1.9.2 moodle installation, at the database level, rather than inside the admin panel of the site.

I need to delete all users who are currently NOT enrolled in any courses and who haven't logged in for more than 30 days. That's are my only parameters. I'm assuming this can be done via a simple SQL query?

I know I need to pull from the mdl_user, mdl_role_assignments and maybe the mdl_role tables, but I'm not sure how to construct this command. I have created a clone install/DB so I can safely test.

Any advice would be greatly appreciated.
 
Average of ratings: -