I have some test users in my V8 umbraco setup. As admin I can only disable these users. Is there an option to delete these users? I can't seem to find this option.
I dont think you can delete users. this is because of the impact it has on the audit table and associated content items, such as who created them, last updated them etc.
It is possible, though it does require running a sql script. Below is the script I use.
DECLARE @userId AS INT = 1
UPDATE umbracoNode SET nodeUser = -1 WHERE nodeUser = @userId
UPDATE umbracoContentVersion SET userId = -1 WHERE userId = @userId
DELETE FROM umbracoLog WHERE userId = @userId
DELETE FROM umbracoUserStartNode WHERE [userId] = @userId
DELETE FROM umbracoUser2NodeNotify WHERE [userId] = @userId
DELETE FROM umbracoUser2UserGroup WHERE [userId] = @userId
DELETE FROM umbracoUserLogin WHERE userID = @userId
DELETE FROM umbracoUser WHERE id = @userId
This script removes the user completely from the system by updating the resources that can't be deleted to point at the root user and then deleting all connected table entries. If the umbracoLog table needs to be preserved, it can be changed to
UPDATE umbracoLog SET userId = -1 WHERE userId = @userId
To get the id of the user, just visit the user in the backoffice. The user's id can be seen in the url (/umbraco/#/users/users/user/{user id}).
Thanks Jesse for sharing and I'd like to add a minor update in case your site instance supports multiple cultures then you will need to add this as well
UPDATE umbracoContentVersionCultureVariation SET availableUserId = -1 WHERE availableUserId = @userId
If we talk about User vs. Member, then script will be different. User means, Umbraco backend user. Member is for customer to login from front-end.
If you wish to delete Member record, use below code.
DECLARE @memberId AS INT = 176574;
DELETE FROM cmsMember2MemberGroup WHERE Member = @memberId;
DELETE FROM cmsMember WHERE nodeId = @memberId;
DELETE FROM cmsContentXml WHERE nodeId = @memberId;
DELETE FROM cmsContentVersion WHERE ContentId = @memberId;
DELETE FROM cmsContent WHERE nodeId = @memberId;
ALTER TABLE umbracoNode NOCHECK CONSTRAINT FK_umbracoNode_umbracoNode_id;
DELETE FROM umbracoNode WHERE id = @memberId;
ALTER TABLE umbracoNode CHECK CONSTRAINT FK_umbracoNode_umbracoNode_id;
So I develop the script a little further, to remove all users if you need, might help someone:
-- Table variable to store the list of user ID
declare @Ids table (Id INT)
declare @userId INT
-- Load the table with the list of users we want to work with
INSERT INTO @Ids (Id)
SELECT [id]
FROM [umbracoUser]
--If need to exclude any user
delete from @Ids where Id = 15;
-- loop through each user
WHILE EXISTS (SELECT Id from @Ids)
BEGIN
SELECT TOP 1 @userId = Id
FROM @Ids
ORDER BY Id ASC
UPDATE umbracoNode SET nodeUser = -1 WHERE nodeUser = @userId
UPDATE umbracoContentVersion SET userId = -1 WHERE userId = @userId
DELETE FROM umbracoLog WHERE userId = @userId
DELETE FROM umbracoUserStartNode WHERE [userId] = @userId
DELETE FROM umbracoUser2NodeNotify WHERE [userId] = @userId
DELETE FROM umbracoUser2UserGroup WHERE [userId] = @userId
DELETE FROM umbracoUserLogin WHERE userID = @userId
DELETE FROM umbracoUser WHERE id = @userId
DELETE FROM @Ids WHERE Id = @userId
END
Delete user
Hi,
I have some test users in my V8 umbraco setup. As admin I can only disable these users. Is there an option to delete these users? I can't seem to find this option.
Thanks you.
Any one?
+1 I am also looking for the same answer
I dont think you can delete users. this is because of the impact it has on the audit table and associated content items, such as who created them, last updated them etc.
I believe you can hide all disabled users.
Do you then change the name and email for the disabled user??
Now that you cant delete the user? I'm thing off GDPR laws here ?..
It is possible, though it does require running a sql script. Below is the script I use.
This script removes the user completely from the system by updating the resources that can't be deleted to point at the root user and then deleting all connected table entries. If the umbracoLog table needs to be preserved, it can be changed to
To get the id of the user, just visit the user in the backoffice. The user's id can be seen in the url (/umbraco/#/users/users/user/{user id}).
Thanks for the script, spot on!
Thanks Jesse for sharing and I'd like to add a minor update in case your site instance supports multiple cultures then you will need to add this as well
Worked a treat. Thanks Jesse
If we talk about User vs. Member, then script will be different. User means, Umbraco backend user. Member is for customer to login from front-end.
If you wish to delete Member record, use below code.
So I develop the script a little further, to remove all users if you need, might help someone:
is working on a reply...