User Suspension

Admin tools ::: tool_usersuspension
Maintained by Sebsoft Plugins, Rogier van Dongen
The Sebsoft User Suspension Plugin offers you the possibility to automate the process of suspending users and/or removing user accounts (using moodle's default methods to delete users).
Latest release:
344 sites
41 fans

The Sebsoft User Suspension Plugin offers you the possibility to automate the process of suspending users and/or removing user accounts (using moodle's default methods to delete users).

Suspending users is provided in three different ways:

  • Using a folder
  • Using a file upload
  • Manually through a status table

Deleting users is, if configured to be enabled, provided by comparing the date of suspending to the configured period before removal. Once the configured interval has past and the user is deemed suspended for the configured period, the useraccount will be removed using moodle's standard methods.

Furthermore, there's extensive settings that can be configured to turn every feature on or off, as well as disabling the whole tool's features.

This tool also provides a way of excluding users to be suspended or processed in case of automated processing. There are two methods provided at the moment: single user exclusion and cohort exclusion. During all three different ways of automated suspending / deleting users, only users that have NOT been configured to be excluded, either by cohort or by single user, will be processed.

Important note

Site administrators and the default guest account are completely left out of this tool. For safety measures, it is not recommended to put any form of automation on suspending or deleting administrator accounts or the default guest account, hence the decision to exclude them in any processing.


Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3
Screenshot #4
Screenshot #5
Screenshot #6
Screenshot #7
Screenshot #8


Sebsoft Plugins (Lead maintainer)
Rogier van Dongen: Project leader
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Tue, Apr 6, 2021, 8:41 PM
    Hi Rogier,
    I have moodle 3.9. I am testing this plugin but the automation to suspend/unsuspend users is not working via the automatic feature. My csv file is saved with ";" and I am using only the email information. I did a change in order to have this files checked every minute but nothing works. Any advice? Thank you. Andrea
  • Tue, Apr 6, 2021, 9:18 PM
    Hi @Andrea, can you pass me a message through either the messaging system on this site or through email (you can find the email address from basically any random file in the plugin sources)?
    I've seen your earlier question as well although it has disappeared from view (maybe you've removed it).
    It's somewhat easier to aid you personally through e.g. email, because I try to avoid long messages here.
    Cheers, Rogier
  • Fri, Apr 30, 2021, 8:59 PM
    Hi Rogier, I thought this plugin was the solution for my problem but it’s not. I want to suspend a user not by inactivity but pure on a period of time. My users pay per Year so I want to suspend then automatically one year after the user is created. Is that something you'll add to functionality of your plugin?
  • Mon, May 3, 2021, 5:14 PM
    Hello Jan,
    Could you message me in person through email (or optionally: message me through the repository issue tracker)?
    I have an idea how to facilitate this but it may just fall outside of scope of the plugin intention depending on optional other requirements you may have.
    Looking forward to seeing your response,
    Cheers, Rogier
  • Ricardo Caiado
    Mon, Oct 11, 2021, 10:39 AM

    Is "User Suspension 3.5.5 (build 2020121500)"compatible with Postgresql 12?

    When accessing "Users to suspend" tab I got this error message:


    Error reading from database

    Debug info: ERROR: function unix_timestamp() does not exist
    LINE 2: ...ccess, u.timemodified) AS timedetect,(31536000 - (UNIX_TIMES...
    HINT: No function matches the given name and argument types. You might need to add explicit type casts.
    SELECT,u.username, '' || u.firstname || ' ' || u.lastname AS name,u.lastlogin,u.firstaccess,u.lastaccess,u.timemodified,u.suspended,u.deleted,GREATEST(u.firstaccess, u.lastaccess, u.timemodified) AS timedetect,(31536000 - (UNIX_TIMESTAMP() - GREATEST(u.firstaccess, u.lastaccess, u.timemodified))) AS suspendin,NULL as action
    FROM mdl_user u
    WHERE (u.confirmed = 1 AND u.suspended = 0 AND u.deleted = 0 AND u.mnethostid = $1 AND ((u.lastaccess = 0 AND u.firstaccess > 0 AND u.firstaccess > $2) OR (u.lastaccess > 0 AND u.lastaccess > $3) OR (u.auth = 'manual' AND u.firstaccess = 0 AND u.lastaccess = 0 AND u.timemodified > 0 AND u.timemodified > $4)) AND NOT IN ($5,$6,$7)) OR (u.confirmed = 1 AND u.suspended = 0 AND u.deleted = 0 AND u.mnethostid = $8 AND ((u.lastaccess = 0 AND u.firstaccess > 0 AND u.firstaccess < $9) OR (u.lastaccess > 0 AND u.lastaccess < $10) OR (u.auth = 'manual' AND u.firstaccess = 0 AND u.lastaccess = 0 AND u.timemodified > 0 AND u.timemodified < $11)) AND NOT IN ($12,$13,$14))
    LIMIT 25
    [array (
    0 => '1',
    1 => 1602383800,
    2 => 1602383800,
    3 => 1602383800,
    4 => 1,
    5 => 2,
    6 => 3,
    7 => '1',
    8 => 1602383800,
    9 => 1602383800,
    10 => 1602383800,
    11 => 1,
    12 => 2,
    13 => 3,
    Error code: dmlreadexception
    Stack trace:

    line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
    line 329 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
    line 920 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
    line 2017 of /lib/tablelib.php: call to pgsql_native_moodle_database->get_records_sql()
    line 2039 of /lib/tablelib.php: call to table_sql->query_db()
    line 231 of /admin/tool/usersuspension/classes/statustable.php: call to table_sql->out()
    line 158 of /admin/tool/usersuspension/classes/statustable.php: call to tool_usersuspension\statustable->render_to_suspend()
    line 88 of /admin/tool/usersuspension/view/statuslist.php: call to tool_usersuspension\statustable->render()
  • Mon, Oct 25, 2021, 8:41 PM
    Hi Ricardo,
    Too bad you didn't really check the main repository for updates because this bug was long fixed already (i can't always keep up with rolling out every change here).
    Anyway: new version is available, please refer to changelog.
  • Thu, Nov 18, 2021, 5:57 PM
    I would have to validate, but to my best recollection, the mandate for Moodle3.5 onwards is there on purpose because the code makes use of some core functionality that only exists from Moodle3.5 onwards (which is why the majority of our plugins only support Moodle 3.5 and up).
    If you're really in need of this plugin and can't upgrade your Moodle, I advise you to contact me personally (see email address in the sources) to see if we can find a way to support your need.
  • Thu, Nov 18, 2021, 6:47 PM
    Dear Rogier, thanks for your quick and swift reply.
    I noticed, after a reload of the Verions page, that there is a Build 3.3.0 for Moodle 3.4. So, I will try that first.
    Is new functionality added since 3.4 -> 3.5 or is code just rewritten to make use of (newly added) core functions ?
  • Thu, Nov 18, 2021, 6:55 PM
    The main functionality in pre 3.5 versions is basically very similar, but there have been substantial additions (which may not really be that important) and a number of fixes. Some of those are specific to changes in the Moodle core in 3.5 onwards, but overall the main plugin functionality doesn't differ all that much.
    For a decent overview, you could download the most recent version and then view the changelog in the archive. That should give you a basic idea of the changes. The majority of them are rather small fixes.
    Having said that: I strongly do advise to first check the plugin outside of a production environment to make sure no users would accidentally be removed or suspended (suspending is no problem, but the plugin does support full removal of users which is an irreversible process!)
    Of course you're always free to ask questions ;)
    Cheers, Rogier
  • Fri, Dec 17, 2021, 2:21 AM
    Great plugin. I am using the folder option and it both suspends and un-suspends a user. Currently it does this ever 30 minutes. I have changed the time to once per minute or every 2 minutes but it still does it ever 30 minutes. I have moodle 3.9

    We use an alert system, so if a student gets a red alert, our databases will automatically upload the suspend.csv file Once the red alert goes off, then it uploads the un-suspend.csv file. This works great. We need our moodle to be available to them quicker than 30 minutes. Some of our classes use Moodle and a student cannot do their work until they are un-suspended.

    I would like to be able to set it ever 5 minutes.


    I do not use the automatic cleanup or other smart features. Just the .csv file features.
  • Fri, Dec 17, 2021, 4:51 PM
    Hi @Larry,
    Can you confirm, or make sure, your background task for this specific task is set to run at the wanted interval?
    Looking through the sources quickly, I realize we never updated the global settings and the setting seems to be unused at the moment.
    I _think _ at some point the decision was made to replace a generic background task with dedicated background tasks to avoid a few issues and it looks like the thing that was forgotten was to update the settings and remove some options that are no longer in use.
    You should be looking at the tasks "fromfolder" in this plugin in your scheduled tasks overview.
    It'd be great if you can confirm this resolves your issue. I'll take a look at cleaning up some unused options, after confirmation, for the next release.
  • Fri, Dec 17, 2021, 10:07 PM
    Thanks for the quick reply. I believe I have the settings correct. It works great just not frequent enough. I do think it ignores the settings on the config.
    Im not sure what your asking.

    Users Suspension Settings are enabled.
    Suspend from Folder Automatic using stored csv file = Yes
    Automatic Unsuspension = Yes
    This does work.

    Upload folder processing interval = 15 minutes but would like it to be 5, but does 30 minutes no matter what minutes I use

    Configuration Check doesn't detect any problems.
    Smart Detection is disabled. this is the way I want it
    Cleanup is disabled. "

    Historical logs show ever 30 minutes.

    Thanks for you help.

  • Fri, Dec 17, 2021, 10:18 PM
    Hi Larry,
    Provided you have sufficient adminstration rights, go to
    site administration -> tab "Server" -> category "Tasks" -> "Scheduled tasks"
    Then, in the list of tasks, locate the task "
    It's very likely the entry there will show "*/30" for the minute column, meaning the background task itself will only run every 30 minutes.
    You have to modify that task by hitting the cog icon and then enter "*/5" (or even */1) there. */5 would imply to run every 5th minute (practically running every 5 minutes).
    Please _do_ be aware that this by itself will not have any effect when your main CRONTAB only runs scheduled tasks every 30 minutes.

    So for this to work every 5 minutes, the following _must_ be true:
    - CRONTAB runs the generic Moodle tasks every 5 minutes
    - The specific scheduled task, as explained above, has to be set to run every 5 minutes (or less).

    The culprit here is that no specific scheduled task will run at the intended frequency if the main task runs at a lower frequency (hence why Moodle says your background tasks should run at least every 5-10 minutes, but preferably _every_ minute).
    Please also be aware the settings you're looking for are by no means part of the settings you're looking at (in fact: the frequency intervals for any task should no longer be part of the plugin settings because it's handled on a different level: the scheduled tasks in Moodle).

    Cheers and good luck!
  • Sat, Dec 18, 2021, 12:01 AM
    I set the task to 5 minutes and that did the trick. Thanks for helping.
    Hopefully when you have time you will correct this in the settings.

    This app will help our school a great deal . Thank you for your hard work on developing this.
  • Sat, Dec 18, 2021, 2:18 AM
    I wish there was a similar plugin that would do the same as this, except it would create a user based on .csv account. I know the bulk imports users, but that is not cron.
1 2 3
Please login to post comments