Hello Anne,
The following info is for the people at the support area (or for a friend with the required knowledge); it will allow them to recover the deleted accounts. Please first see about the "Important notes" at the end of the post.
1. Run the following SQL statement:
SELECT id,
username,
firstname,
lastname,
email
FROM mdl_user
WHERE deleted = 1
That should get you a table with all the "deleted" users; something like this (I'm just showing one record; in your case you'll get many):
id | username | firstname | lastname | email |
7 |
x5@example.com.1409337561 |
x5fn |
x5ln |
e3d704f3542b44a621ebed70dc0efe13 |
As shown, the query returns the Id, along with other useful data, of those accounts that have been deleted. The support area will have to send you the results so you may then send them back the list with the Id of the accounts you wish to be recovered.
Now, to undelete the required accounts they will need to run...
First this SQL statement:
UPDATE mdl_user
SET deleted = 0,
email = LEFT( username, LENGTH( username ) - 11 )
WHERE id = #'
OR id = #''
OR id = #'''
and then this one:
UPDATE mdl_user
SET username = CONCAT( "user_", CAST( id AS CHAR ), "_rec" )
WHERE id = #'
OR id = #''
OR id = #'''
Finally, the following query will allow to confirm about the changes done to the table:
SELECT id,
username,
firstname,
lastname,
email
FROM mdl_user
WHERE id = #'
OR id = #''
OR id = #'''
This query will return the list of the recovered accounts; something like this:
id | username | firstname | lastname | email |
7 |
user_7_rec |
x5fn |
x5ln |
x5@example.com |
Important notes.
1. The prefix "mdl_" of the user table is the default prefix used on a normal installation, but another prefix could have been used; if that were the case, then the SQL statements will have to be adjusted as required.
2. The number 11 at the second query (the first update query) refers to the number of characters to be skipped from the deleted username (shown at the first result table) in order to get the original email address.
3. The #', #'', #''' strings represent the Id numbers of the accounts to be recovered, so those strings need to be substituted with the real Id numbers, for example:
WHERE id = 7
OR id = 22
etc.
4. As shown in the last table, a username string was created based on the Id of the user; it will need to be updated by the Moodle admin with the correct, original value, for each user, through the User profile page.
https://docs.moodle.org/27/en/Update_profile