Inactive User Cleanup

Admin tools ::: tool_inactive_user_cleanup
Maintained by Arindam Ghosh, DualCube Team
This plugin deletes inactive user accounts. This cleanup process runs with Moodle cron job.
Latest release:
182 sites
44 fans
Moodle 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8

In the first step admin user of the site setup days of inactivity and drafting notification mail for all users from the Site administration > Reports > Inactive User Cleanup

If an inactive user is found he/she gets a notification mail.

In second step if the user still has not accessed the moodle site within the time span which is mentioned in the notification mail. Then the deletion process starts. The particular inactive     user account entry is removed with next run of this cleanup process which is automatically or manually run by cron process.


Some setting is require for this cleanup process.

Setting Panel

Days of Inactivity is set by the admin user.

Days Before Deletion is set with zero when admin just wants to notify the inactive user for access the site i.e. in first step. After that when user wants to run cleanup process then Days Before Deletion will set by the admin user.

Email setting

Admin user must set the subject and body text of the email.

Cron process

Admin user run cron job manually from http://<moodlename>/admin/cron.php


Admin can uninstall this admin tool from Site administration > Plugins > Admin tools > Manage Admin Tools


  • DualCube


Screenshot #0


Arindam Ghosh (Lead maintainer)
DualCube Team: Developer
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Mon, Sep 2, 2019, 1:38 PM
    The version downloaded here doesn't seem to match the code on the Source Control URL (
    In this version, on Moodle 3.6.4 (Build: 20190513) PHP Version 7.0.33-0+deb9u3 during installaiton I get

    Fatal error: Namespace declaration statement has to be the very first statement in the script in [...snip] /admin/tool/inactive_user_cleanup/classes/task/tool_inactive_user_cleanup_task.php

    Easy enough to put the `namespace` ahead of the `defined` to fix it
  • Mon, Oct 21, 2019, 7:38 PM
    I'm using the latest moodle 3.7.2 together with this plugin. I setup 365 days of inactivity with 14 days before the deletion. The majority of users are using oauth2 for office365 and the other the standard login. Today all the users have been deleted even active ones. How is possible?
    Thank you
  • Mon, Oct 21, 2019, 8:02 PM
    Inactive user clean-up plugin checks for the login log, in Moodle. When you have used oAuth for SSO login, Moodle did not get any login log. So the users are inactive still. This is the reason for such a phenomenon. Please restore the users by database restoration.

    Thank you.
  • Mon, Jan 13, 2020, 12:38 AM
    Okay, I am running Moodle 3.7 on PHP 7.3. Everything works beautifully except for this plugin. I've installed it many times in different ways but it keeps crashing, and this happens to be a very important plugin that I need to be able to use. I also cannot find an alternative.

    It crashes and it completely stops my Cron from working, at all. Once i uninstall it, the cron works properly again.
    Then I will reinstall it, I've tried zip file, and I've tried instlaling through the browser, and it crashes within a few hours everytime.

    the error it gives me is:
    /home/llumenam/ on line 28

    but line 28 is:
    namespace tool_inactive_user_cleanup\task;

    i don't understand what this means, it looks normal to me.
  • Wed, Mar 25, 2020, 5:00 AM
    Hi Jean Clark, the problem is probably already solved. I had the same problem. The plugin in its current version is programmed incorrectly. The abort leads to the fact that no more "planned processes" are recorded for the cronjobs. So the error has serious consequences. I finally deleted the plugin. But there is a workaround, which can be seen in the error message. You have to put the statement in the error line on top of the class (tool_inactive_user_cleanup_task.php). Namespaces have to be in the code first. I don't know if this is the only problem. Therefore I have deleted the plugin. Kind regards, Andreas
  • Wed, Mar 25, 2020, 2:02 PM
    Dear Jean,

    Please set up your SMTP properly from the outgoing mail configuration. Then test the outgoing mail configuration. After it is tested OK, please run the cron. It should solve the issue.

    Thank you.
  • Fri, Apr 17, 2020, 6:08 PM
    Dear DualCube Team,
    Users who just created an account but haven't logged in yet, will they also be seen as inactive users and get an notification mail? Because when I use a filter in "brows list of users" to select only the users whose last visit was 1 year ago, users who never logged in are also shown in this selection.
    Kind regards,
    Esther Peek
  • Wed, Jun 10, 2020, 2:42 PM
    Dear DualCube Team,
    I am using Moodle 3.7 on PHP 7.3 everything is working fine but there is one problem that I am facing, when I installed the plugin schedule task were not showing.
    i.e. schedule task were blank after plugin install. So, how can I schedule the time for this plugin and others too.
    Have any idea why it is happening ??

  • Wed, Jun 10, 2020, 7:57 PM
    Dear Amit,
    It might be that both use a cron job to do the job. We will check the compatibility issue and fix it .

    Thank you.
  • Mon, Aug 24, 2020, 1:57 AM
    I ran into a problem with moodle's built-in privacy tool: whenever there's an export job of user data initialized throug a data request, the task "\tool_dataprivacy\task\process_data_request_task" always stops at: "tool_inactive_user_cleanup wird verarbeitet (273/509) (Sonntag, 23. August 2020, 19:14)", so it's impossible for users to retrieve their data. I deinstalled your Plugin and the process works fine now. Any idea, why this happens?
  • Tue, Sep 1, 2020, 8:19 PM
    Dear Conrad,
    Can you please let me know the version of Moodle that you are using ?
    Thank you.
  • Wazza
    Tue, Sep 22, 2020, 4:51 PM
    A good enhancement to this plugin would be the option to select the athentication method for user cleanup. Our situation is as follows: we have SAML users that do NOT need to be cleaned up. Their accounts will be disabled automatically when they leave the organisation (students and teachers). However, we also have manual accounts for guest-teachers etc. These do need to be cleaned up automatically. I think this will be the case with most Moodle installs: only the manual accounts need to be cleaned up.
  • Thu, Oct 1, 2020, 7:11 PM
    Thanks Rechard, we will take this into consideration in our next update.

  • Tue, Oct 20, 2020, 6:14 PM
    Little mistake in published version :
    Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in /var/www/moodle35-cy-origin-qualif/admin/tool/inactive_user_cleanup/classes/task/tool_inactive_user_cleanup_task.php on line 28

    concerns the task class, but also the default provider. namespace declaration should be sooner than the MOODLE_INTERNAL control.
  • Wed, Jul 28, 2021, 2:29 AM
    Is this plugin supported on Moodle LTS 3.9.X?

    Am currently running version 3.9.2 and 3.9.8 (2 platforms).

1 2 3 4
Please login to post comments