Inactive User Cleanup icon

Inactive User Cleanup

Maintained by DualCube Team
The inactive user cleanup is a useful solution that deletes an inactive user's account automatically. Additionally, the solution sends users emails informing them before deleting their account. Thus, if a learner logs in before the account is deleted, he or she will not be removed from the system.
Price option: Free

Supports Moodle 2.4-5.0 See all versions
Latest release: 1 year ago
Installations: 329
Downloads (last 90 days): 125

Frankenstyle name: tool_inactive_user_cleanup
Administration tools

Comments

Product ratings and reviews are coming to Moodle Marketplace. Until then, existing comments remain available to read, but new posts have been disabled.

Hi Becka, thank you for your query!
To ensure you receive the best assistance, I kindly recommend reaching out to our development team directly via this link:https://dualcube.com/contact-us/. They will be able to provide you with more detailed support.
This would save me so much time with maintenance... BUT I have a question. Is there an option, or can one be created, where one can list users to *never* be removed from the system?
For example, part of our school policy is if you get caught plagiarizing, or you accumulate and max out the set number of demerits/marks (scoring system for rule-breaking), or are excessively hostile to school staff, you're suspended for a certain length of time based on the severity of the infractions. (And would be outside the timeframe I use to remove inactive users.)
And, we have a few accounts that only get used periodically (often outside of the timeframe I use for manually removing idle users), plus a couple I use as "sample" students for testing features and making tweaks.
I DO NOT want those to ever get deleted. So this would be great, if there were a way to say "exclude these users from the deletion process." Is that doable? Or in the works?
Like I said, this would save me so much work in the user maintenance "department", and I wouldn't have to mess with csv files with user data (and "shredding" it later) like I'm currently doing.
Hi Mark, please download and use the latest version of the Inactive Cleanup plugin from GitHub at this link: https://github.com/dualcube/moodle-tool_inactive_user_cleanup, and check again whether the issue has been fixed.
Hi Mark, sorry to hear that you have faced this issue.
Our team is looking into this. For now you can track the issue from here - https://github.com/dualcube/moodle-tool_inactive_user_cleanup/issues/29
Hi - I have the same issue as above. Using Moodle 4.3.3 and the latest version of the plugin (2.7.4) I see the following error message:
Exception occurred while calling tool_inactive_user_cleanup\privacy\provider::get_contexts_for_userid.
This means that plugin tool_inactive_user_cleanup did not complete the processing of data. The following exception information may be passed on to the plugin developer:
ERROR: Incorrect number of query parameters. Expected 3, got 2.
#0 /home/xxx/public_html/lib/dml/mysqli_native_moodle_database.php(1331): moodle_database->fix_sql_params('\n ...', Array)
#1 /home/xxx/public_html/privacy/classes/local/request/contextlist.php(71): mysqli_native_moodle_database->get_recordset_sql('\n ...', Array)
#2 /home/xxx/public_html/admin/tool/inactive_user_cleanup/classes/privacy/provider.php(148): core_privacy\local\request\contextlist->add_from_sql('SELECT c.id\n ...', Array)
#3 /home/xxx/public_html/lib/moodlelib.php(8292): tool_inactive_user_cleanup\privacy\provider::get_contexts_for_userid(41872)
#4 /home/xxx/public_html/privacy/classes/manager.php(578): component_class_callback('tool_inactive_u...', 'get_contexts_fo...', Array)
#5 /home/xxx/public_html/privacy/classes/manager.php(611): core_privacy\manager::component_class_callback('tool_inactive_u...', 'core_privacy\\lo...', 'get_contexts_fo...', Array)
#6 /home/xxx/public_html/privacy/classes/manager.php(238): core_privacy\manager->handled_component_class_callback('tool_inactive_u...', 'core_privacy\\lo...', 'get_contexts_fo...', Array)
#7 /home/xxx/public_html/admin/tool/dataprivacy/classes/task/process_data_request_task.php(93): core_privacy\manager->get_contexts_for_userid(41872)
#8 /home/xxx/public_html/lib/classes/cron.php(508): tool_dataprivacy\task\process_data_request_task->execute()
#9 /home/xxx/public_html/lib/classes/cron.php(302): core\cron::run_inner_adhoc_task(Object(tool_dataprivacy\task\process_data_request_task))
#10 /home/xxx/public_html/lib/classes/cron.php(128): core\cron::run_adhoc_tasks(1726563604, 0, true, 1726563602)
#11 /home/xxx/public_html/admin/cron.php(80): core\cron::run_main_process(0)
#12 {main}
Thanks in advance.
Mark
Hi @Gabriel Richard, it seems like your php.ini is not configured properly. Please set the max_var value above 5000 and check again.
Do keep us posted.
After trying to install the plugin, the Moodle site performed the checks and everything was OK.
Only at the end of the listing did the max-input-vars message appear: "if this test fails, it will indicate a problem. It is recommended that the PHP configuration of max-input-vars be at least 5000."
After clicking OK, the site did not proceed with the installation and got stuck in a loop at this requirement checking phase. I managed to cancel the plugin installation, but now the site remains in the same update loop. However, there is nothing about the plugin and the max-input-vars.
My moodle ios Moodle 4.0.6+ (Build: 20230224)
Nome Informação Relatório Plugin Status
moodle
a versão 3.6 é necessária e você está usando a versão 4.0.6+ (Build: 20230224)
OK
unicode
deve ser instalado e habilitado
OK
database mariadb (5.5.5-10.2.38-MariaDB-log)
a versão 10.2.29 é necessária e você está usando a versão 10.2.38
OK
php
a versão 7.3.0 é necessária e você está usando a versão 7.4.26
OK
pcreunicode
recomendado como instalado/habilitado
OK
php_extension iconv
deve ser instalado e habilitado
OK
php_extension mbstring
deve ser instalado e habilitado
OK
php_extension curl
deve ser instalado e habilitado
OK
php_extension openssl
deve ser instalado e habilitado
OK
php_extension tokenizer
recomendado como instalado/habilitado
OK
php_extension xmlrpc
recomendado como instalado/habilitado
OK
php_extension soap
recomendado como instalado/habilitado
OK
php_extension ctype
deve ser instalado e habilitado
OK
php_extension zip
deve ser instalado e habilitado
OK
php_extension zlib
deve ser instalado e habilitado
OK
php_extension gd
deve ser instalado e habilitado
OK
php_extension simplexml
deve ser instalado e habilitado
OK
php_extension spl
deve ser instalado e habilitado
OK
php_extension pcre
deve ser instalado e habilitado
OK
php_extension dom
deve ser instalado e habilitado
OK
php_extension xml
deve ser instalado e habilitado
OK
php_extension xmlreader
deve ser instalado e habilitado
OK
php_extension intl
deve ser instalado e habilitado
OK
php_extension json
deve ser instalado e habilitado
OK
php_extension hash
deve ser instalado e habilitado
OK
php_extension fileinfo
deve ser instalado e habilitado
OK
php_extension sodium
recomendado como instalado/habilitado
OK
php_extension exif
recomendado como instalado/habilitado
OK
php_setting memory_limit
configuração recomendada detectada
OK
php_setting file_uploads
configuração recomendada detectada
OK
php_setting opcache.enable
configuração recomendada detectada
OK
Hi, we have added the fix on our end. Kindly install this plugin from our GitHub repository - https://github.com/dualcube/moodle-tool_inactive_user_cleanup/archive/refs/heads/master.zip
Please let us know if this fixed the issue.
Regards,
Team DualCube
Further on the issue reported by Dr. Nellie Deutsch :
Exception occurred while calling tool_inactive_user_cleanup\privacy\provider::get_contexts_for_userid.
I would like to share more details about the bug. The issue is present in the following file :
admin/tool/inactive_user_cleanup/classes/privacy/provider.php Line no 144
in the function "get_contexts_for_userid"
$sql = "SELECT c.id
FROM {context} c
INNER JOIN {user} u ON u.id = :userid
LEFT JOIN {tool_inactive_user_cleanup} iu ON iu.userid = u.id
WHERE c.contextlevel = :contextlevel
AND c.instanceid = u.id
AND u.id = :userid";
You have used 3 named parameters in the SQL :userid, :contextlevel and :userid
while you are passing only 2 parameters in $params :
$params = [
'contextlevel' => CONTEXT_MODULE,
'discussionuserid' => $userid,
];
Due to this in the function "fix_sql_params" defined in :
lib/dml/moodle_database.php Line no 954
It triggers and exception that the query requires 3 parameters but there are only 2 parameters passed as we can see in $params.
If you pass 3 named parameters in query Moodle expects exact 4 parameters in $params
This is the 1st error even if this is passed this query will get caught at the following lines in
lib/dml/moodle_database.php
1. Line no 980 throw new dml_exception('missingkeyinsql', $key, '');
Since :userid is used but there is no value for userid in $params
2. Line no 990 throw new dml_exception('duplicateparaminsql');
Moodle does not expect two same named parameters (i.e. :userid and :userid) to be used in the sql query
It looks like the issue started around 3 weeks back when this commit was released :
https://github.com/dualcube/moodle-tool_inactive_user_cleanup/commit/603b6697269608cb8e6c5e94cb81de9247315023
A fix for this would look like this :
$sql = "SELECT c.id
FROM {context} c
INNER JOIN {user} u ON u.id = :juserid
LEFT JOIN {tool_inactive_user_cleanup} iu ON iu.userid = u.id
WHERE c.contextlevel = :contextlevel
AND c.instanceid = u.id
AND u.id = :wuserid";
$params = [
'contextlevel' => CONTEXT_MODULE,
'juserid' => $userid,
'wuserid' => $userid,
];
Please check from your end and try to replicate this issue.
Hi @Dr. Nellie Deutsch, we are not able to recreate the same on our end. Can you please contact us over here - https://dualcube.com/contact-us/, so we can assist you with this.
It's happening on all of my Moodle 4.4 sites. I only get the message in my inbox for 4.4 not for 4.3. I have no idea how you can replicate it except to try it out on Moodle 4.4 which I presume you have.
Hi @Dr. Nellie Deutsch, We're sorry to hear that you've encountered this issue.
We've investigated on our end, but unfortunately, we're unable to replicate it. Could you please provide us with more details on how we can recreate this issue? This will help us assist you further.
Thank you for upgrading to 4.4. This is what I get in my inbox. The message suggest that I share the error with you so here it is: Exception occurred while calling tool_inactive_user_cleanup\privacy\provider::get_contexts_for_userid.
This means that plugin tool_inactive_user_cleanup did not complete the processing of data. The following exception information may be passed on to the plugin developer:
ERROR: Incorrect number of query parameters. Expected 3, got 2.
#0 /home/integrating/public_html/lib/dml/mysqli_native_moodle_database.php(1331): moodle_database->fix_sql_params()
#1 /home/integrating/public_html/privacy/classes/local/request/contextlist.php(71): mysqli_native_moodle_database->get_recordset_sql()
#2 /home/integrating/public_html/admin/tool/inactive_user_cleanup/classes/privacy/provider.php(148): core_privacy\local\request\contextlist->add_from_sql()
#3 /home/integrating/public_html/lib/moodlelib.php(8292): tool_inactive_user_cleanup\privacy\provider::get_contexts_for_userid()
#4 /home/integrating/public_html/privacy/classes/manager.php(578): component_class_callback()
#5 /home/integrating/public_html/privacy/classes/manager.php(611): core_privacy\manager::component_class_callback()
#6 /home/integrating/public_html/privacy/classes/manager.php(238): core_privacy\manager->handled_component_class_callback()
#7 /home/integrating/public_html/admin/tool/dataprivacy/classes/task/process_data_request_task.php(93): core_privacy\manager->get_contexts_for_userid()
#8 /home/integrating/public_html/lib/classes/cron.php(508): tool_dataprivacy\task\process_data_request_task->execute()
#9 /home/integrating/public_html/lib/classes/cron.php(302): core\cron::run_inner_adhoc_task()
#10 /home/integrating/public_html/lib/classes/cron.php(128): core\cron::run_adhoc_tasks()
#11 /home/integrating/public_html/admin/cli/cron.php(186): core\cron::run_main_process()
#12 {main}
Hi Robert, our team is checking the pull request, we will keep you posted.
Hi, thanks for your work!
Since there is a merge-request open, do you plan to release this update?