Admin tools: User Restore

tool_userrestore
Maintained by Picture of Sebsoft Plugins Sebsoft Plugins, Picture of Rogier van Dongen Rogier van Dongen
The Sebsoft User Restore Plugin offers you the possibility to restore user accounts that were deleted from moodle.
171 sites
166 downloads
17 fans

The Sebsoft User Restore Plugin offers you the possibility to restore user accounts that were deleted from moodle.

When the plugin has been installed, you can select a number of user accounts to restore and optionally send an email informing them their accounts have been restored.

This plugin takes the following into account:

  • Users to be restored are checked on e-mail: if an e-mail address already exists for an active account, this user will not be restored.
  • Users to be restored are checked on username: if an username already exists for an active account, this user will not be restored.
  • Users to be restored are checked on MNET host: if the MNET host of the account to be restored is not the locally configured one, this user will not be restored.

Important note

Moodle removes ALL relevant data upon deleting a user account, and only the record in the user table itself remains. This utility can't do anything about this and is only capable of restoring the record from the user table.

Important note for moodle 2.7 and up

Before Moodle 2.7 there is NO way we can retrieve all information. However, with Moodle 2.7 and the new event logging tables, the original user information is stored in the event data. Therefore, from Moodle 2.7 onwards, this plugin will try and restore the original user information from there.

This effectively means, that from Moodle 2.7 onwards, we will have the correct original username, email, idnumber, picture and mnethostid. Before that, only the email could be restored, and even that method is not foolproof (due to the fact the username is cleaned with PARAM_USERNAME upon deletion).

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3
Screenshot #4

Contributors

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

Comments RSS

Show comments
  • Picture of Plugins bot
    Wed, 22 Apr 2015, 3:51 AM
  • Picture of David Mudrák
    Mon, 25 May 2015, 4:49 PM

    Thanks for sharing this plugin with the community and for your patience with the review and approval process. It looks good now to be approved. You are cleared to land, welcome to the Plugins directory. I am now going to remove the previous implementation of the plugin (block_userrestore).

  • Picture of David Mudrák
    Mon, 25 May 2015, 5:12 PM

    Oh, only now I realized I am getting "Access denied" when trying to access your bugtracker at Bitbucket. Can you please check the permissions to make sure that the community is able to report issues for you there? Same applies to your User suspension tool, too.

    What I was going to report was: When a user is deleted after being suspended for a while (as a result of the User suspension tool's action) and then is restored via this tool, it is restored in the suspended state. I don't think that is the expected behaviour. I guess the admin wants to see the account enabled after being restored. Also, Moodle does not send any messages to suspended accounts. So the restored user is not notified about his account being available again.

  • Picture of Sebsoft Plugins
    Mon, 25 May 2015, 6:30 PM
    Hello David, thanks for noticing our bugtrackers still being private, I've made them public.
    I will check into the unexpected behavior soon and update plugin accordingly to see the more expected behavior of undoing any suspension states when restoring the account so moodle will send the notification email accordingly. Thanks for clearance!
    Cheers
  • Picture of Sebsoft Plugins
    Fri, 19 Jun 2015, 9:02 PM
    New version includes fix as reported by David: upon restore, "suspended" state is always set to 0 so behavior is more as expected. As mentioned, this fix will now make sure the restored user receives any email sent (if applicable)
  • Picture of Santiago Garcia
    Sat, 19 Sep 2015, 7:38 AM
    Hello, thanks for the plugin
    After installation the plugin hands and never loads the page, im using moodle 2.9 and a mysql database
  • Picture of Sebsoft Plugins
    Mon, 21 Sep 2015, 10:30 PM
    Hello Santiago,
    I'm unable to reproduce your issue on a clean Moodle2.9.1 environment running MySQL.
    However I sent you a personal message on how to contact us with more information and possibly, screenshots.
    Cheers!
  • Picture of David Eisaura
    Thu, 24 Sep 2015, 11:46 PM
    I just used this tool, and it seems to have performed flawlessly. Thank you!
  • Picture of Jarrod Miles
    Wed, 15 Feb 2017, 7:22 PM
    After attempting to load the restore.php page in admin tools in Moodle 2.9.1, it's hung (even after 30 minutes of waiting).
    Seems to be continually cycling through

    SELECT CONCAT(firstname, ' ', lastname) AS deletedby, u.id AS deletedbyid, l.timecreated AS timedeletedby FROM mdl_logstore_standard_log l JOIN mdl_user u ON l.userid=u.id WHERE component = 'core' AND action= 'deleted' AND l.target = 'user' AND l.objectid = 'XXXX' ORDER BY l.timecreated DESC LIMIT 1

    as well another query. There are almost 7000 users on the Moodle.
  • Picture of Sebsoft Plugins
    Thu, 23 Feb 2017, 5:36 AM
    Hi Jarrod,

    This seems to be the query to detect who deleted the user. It might be wiser to disable that field if the tables are too big...
    Did it work in the end?
  • Picture of Rogier van Dongen
    Fri, 12 May 2017, 7:44 PM
    New version is here!
    No real changes worth mentioning other than a code overhaul to comply to stricter Moodle Coding Standards.
    Functionality tested up to Moodle 3.3
    On the roadmap (Jarrod Miles, thanks for bringing up this issue): think of a better method of generating the lists for restoring users. Either by pagination or (preferred) a searchbox / user picklist.

    Cheers!
  • Picture of Rogier van Dongen
    Mon, 25 Sep 2017, 10:20 PM
    New version is here!
    Changes for Version 3.3.0 (build 2017092500)
    * Fixed deprecated pix_url references (replaced by image_url)
    * Added setting for maximum number of users to display on restore.php / restore form
    * Added paging bar on restore.php
    * Minimum required Moodle version: 3.3

    Cheers!
  • Ricardo Caiado
    Sat, 17 Mar 2018, 10:52 PM
    Hi,

    Any update to Moodle 3.4?

    Ricardo
  • Picture of Premi Sivanesan
    Tue, 29 May 2018, 2:59 PM
    Hi there
    I installed the plugin on 3.3 and every time I tried to use it, the Moodle site goes down.
    Any help would be appreciated.

    Premi
Please login to post comments