It's not possible to completely delete users via the Umbraco UI. This is because users may have data associated with them throughout the system (e.g if a user modifies a page, the modification will be saved alongside the user as part of the audit trail). To delete a user may corrupt the audit trail. So if you need to delete a user, check first for dependencies, then delete via the database directly.
Oh, btw, still don't like the idea of deleting users.. if you want to get rid of those in the admin backend, here's another idea I've implemented a while ago:
Build your own loadUsers functionality to NOT show disabled users.
There is really no reason to use brute force to remove users (user-ids) from the database and effectively remove important historical information from documents. - if you "Disable a User" in user admin, then when you refresh the list of users, that user is gone. The user is still in the database, but the user list is effectively pruned. There is no reason to delete those entries in the database as they like are benign cysts of the kidney. They aren't causing any problems so surgeons don't remove them. Altering Umbraco code via loadUsers is completely unecessary as disable user does the same thing - it would appear.
One would thus invoke the old saying, "out of sight - out of mind". Test edit
I'd like to pitch in here, I have to disagree with most people, saying that there is no need to delete a user. I use Umbraco in a business way, I mean I build websites using it, then I "deliver" the websites to the clients. Two things happen here:
First I have to clean the database of test users / development users before I deliver to the client. I can ignore those oldusers, but the client has all the right to not want these "remains" from the development of his website lying around. Imagine if you bought a new house and you could not "clean it". So I understand completely the technical value of keeping hisroty and such, but the reality is that in a development state, I want to loose that history as it is not yet relevant.
Secondly, I create a base Umbraco project from which I "launch" all my new projects, these allow me to offer more functionnality to my clients with less time / cost. But from this "base" project, I have development users that I want to delete and again, I cannot. There are also issues when I'm rebasing my "base" project, these users will / may get carryed over.
I'm not expecting a smooth workaround / solution but I want to re-align the discussion into real-world client delivery processes where things like this do matter.
Here's how I do this. This method does preserve things like audit trail, but re-assigns these back to the initial admin user (User ID #0) so that nothing really "breaks".
Note, the script below deletes ALL users other than this initial user, but with limited SQL knowledge you can adjust to target just the user you want.
-- don't nuke these records, but can re-assign back to "admin" master user (or whoever else)
UPDATE umbracoNode SET nodeUser = 0 WHERE nodeUser > 0
UPDATE cmsDocument SET documentUser = 0 WHERE documentUser > 0
-- these can be nuked
DELETE FROM umbracoLog WHERE userId > 0
DELETE FROM umbracoUser2App WHERE [user] > 0
DELETE FROM umbracoUserLogins WHERE userID > 0
DELETE FROM umbracoUser WHERE id > 0
P.S. not recommended if you're not comfortable with SQL. This works on version 4.11, can't guarantee 6 or above yet.
I sorted this one by opening up the database and deleting the rows for the users I needed to remove. There's some foreign key dependency, so you will get an error message when you try to delete each user. Just check the user ID, then the error message, and then delete the other entry first. In my case my bad user just had a mapping from user -> "application" (which was one of those "content"/ "media" things. I zapped that, and now that bad user's gone.
Anyone have some updates or insights on removing users from an umbraco 7 site? We have alot of users that we would like to remove. Is the script way a possible solution, and if it is, what to watch out for?
Using umbraco for a business knowledge base. Would be nice to at least be able to organize the disalbed users into a seperate folder or hide them from the user list if one is not able to delete them.
Just for the record: it has slightly changed in the latest versions of Umbraco. I've used a below snippet to perform a cleanup of all users despite of the admin (userId: 0) user.
UPDATE umbracoNode SET nodeUser = 0 WHERE nodeUser > 0
UPDATE cmsDocument SET documentUser = 0 WHERE documentUser > 0
DELETE FROM umbracoLog WHERE userId > 0
DELETE FROM umbracoUserStartNode WHERE [userId] > 0
DELETE FROM umbracoUser2NodeNotify WHERE [userId] > 0
DELETE FROM umbracoUser2UserGroup WHERE [userId] > 0
DELETE FROM umbracoUserLogin WHERE userID > 0
DELETE FROM umbracoUser WHERE id > 0
Here's a slightly more complicated script that will delete all disabled users (except the one you nominate) and it will re-assign all the 'blame' to that one
declare @deletedRepresentativeId int = 1 -- make sure this is a user you don't want.
update umbracoUser set userName = 'Delted User', userLogin='20190502__', userEmail = '[email protected]' where id = @deletedRepresentativeId
declare @userIdsToDelete TABLE (id int)
Insert into @userIdsToDelete (id) select id from umbracoUser where userDisabled = 1 AND id != @deletedRepresentativeId
--select * from umbracoUser where Id in (select id from @userIdsToDelete)
-- select *
delete
from [umbracoUser2UserGroup]
where userId in (select id from @userIdsToDelete)
-- select *
delete
from [umbracoUserStartNode]
where userId in (select id from @userIdsToDelete)
-- select *
delete
from [umbracoUserLogin]
where userId in (select id from @userIdsToDelete)
update umbracoNode
set nodeUser = @deletedRepresentativeId
where nodeUser in (select id from @userIdsToDelete)
update [cmsDocument]
set documentUser = @deletedRepresentativeId
where documentUser in (select id from @userIdsToDelete)
update [umbracoLog]
set userId = @deletedRepresentativeId
where userId in (select id from @userIdsToDelete)
delete from umbracoUser where id in (select id from @userIdsToDelete)
Deleting Users
hey there,
I've a question in using the usersarea. How can I delete users? I don't want to deactivate them. I want to delete.
Thank you for the coming response.
PS. Sorry my English isn't perfect I know. I really hope, that you understood what I want to do.
It's not possible to completely delete users via the Umbraco UI. This is because users may have data associated with them throughout the system (e.g if a user modifies a page, the modification will be saved alongside the user as part of the audit trail). To delete a user may corrupt the audit trail. So if you need to delete a user, check first for dependencies, then delete via the database directly.
Hope this helps...
Thank you for your response.
the users that i want to delete are useres i onely createt for testing reasons.
There were no posts ore something else i did with them.
so were can i delete them in the database directly?
looking for a reponse :D
The 'umbracoUser' table should be the one you want.
sorry but i can't find it in the ftp.
where should i search for it ?
users are stored in the database, not on file system. As Dan points out, look for the umbracoUser table in the umbraco database.
Cheers,
/Dirk
Oh, btw, still don't like the idea of deleting users.. if you want to get rid of those in the admin backend, here's another idea I've implemented a while ago:
Build your own loadUsers functionality to NOT show disabled users.
Cheers,
/Dirk
There is really no reason to use brute force to remove users (user-ids) from the database and effectively remove important historical information from documents. - if you "Disable a User" in user admin, then when you refresh the list of users, that user is gone. The user is still in the database, but the user list is effectively pruned. There is no reason to delete those entries in the database as they like are benign cysts of the kidney. They aren't causing any problems so surgeons don't remove them. Altering Umbraco code via loadUsers is completely unecessary as disable user does the same thing - it would appear.
One would thus invoke the old saying, "out of sight - out of mind". Test edit
I'd like to pitch in here, I have to disagree with most people, saying that there is no need to delete a user. I use Umbraco in a business way, I mean I build websites using it, then I "deliver" the websites to the clients. Two things happen here:
First I have to clean the database of test users / development users before I deliver to the client. I can ignore those oldusers, but the client has all the right to not want these "remains" from the development of his website lying around. Imagine if you bought a new house and you could not "clean it". So I understand completely the technical value of keeping hisroty and such, but the reality is that in a development state, I want to loose that history as it is not yet relevant.
Secondly, I create a base Umbraco project from which I "launch" all my new projects, these allow me to offer more functionnality to my clients with less time / cost. But from this "base" project, I have development users that I want to delete and again, I cannot. There are also issues when I'm rebasing my "base" project, these users will / may get carryed over.
I'm not expecting a smooth workaround / solution but I want to re-align the discussion into real-world client delivery processes where things like this do matter.
Cheers!
You have a good point Sebastien!
I have the same problem here.
Cheers!
I second Sebastien.
Has anyone used F.L.A.M Hosekeeping? I attempted to install it with Umbraco 6.0.3 with no luck unfortunatly :-(
Here's how I do this. This method does preserve things like audit trail, but re-assigns these back to the initial admin user (User ID #0) so that nothing really "breaks".
Note, the script below deletes ALL users other than this initial user, but with limited SQL knowledge you can adjust to target just the user you want.
P.S. not recommended if you're not comfortable with SQL. This works on version 4.11, can't guarantee 6 or above yet.
Best of luck!
I forgot to mention, you should first disable/se-activate the user in the Users section of the backend. THEN run this script.
I sorted this one by opening up the database and deleting the rows for the users I needed to remove. There's some foreign key dependency, so you will get an error message when you try to delete each user. Just check the user ID, then the error message, and then delete the other entry first. In my case my bad user just had a mapping from user -> "application" (which was one of those "content"/ "media" things. I zapped that, and now that bad user's gone.
Hi,
Anyone have some updates or insights on removing users from an umbraco 7 site?
We have alot of users that we would like to remove. Is the script way a possible solution, and if it is,
what to watch out for?
regards
Robert
Using umbraco for a business knowledge base. Would be nice to at least be able to organize the disalbed users into a seperate folder or hide them from the user list if one is not able to delete them.
Just for the record: it has slightly changed in the latest versions of Umbraco. I've used a below snippet to perform a cleanup of all users despite of the admin (userId: 0) user.
Hi Marcin
How will the above SQL snippet affect content nodes that have been created by the deleted users?
/Jan
That's a very good question. This script won't. It needs to be updated and contain the lines from the previously shared in this thread one.
In my case - there is no content yet :) I'll update my answer. Thanks for spotting it!
Here's a slightly more complicated script that will delete all disabled users (except the one you nominate) and it will re-assign all the 'blame' to that one
Hi Murray,
On the 2nd line, should this read:
instead of:
Also, I’m assuming I’ll need to change both these properties to the Id and Email of the admin I’d like to retain?:
is working on a reply...