How to Delete Umbraco User Permanently
Table of contents
As you may have already noticed, the Umbraco back-office panel does not have a built-in user removal option. When you log in and visit the Users section you will see, that you can only deactivate a user.
What's cool, it's possible to easily hide these inactive users, which I will show later in this article.
However, for various reasons such as GPDR, deactivating users may not be a sufficient solution.
When soft delete is not an option, the easiest way to terminate the Umbraco user is to execute a SQL script.
Below you will find a full SQL snippet allowing to remove Umbraco user from the database.
You can use this piece of code directly in SQL Server Management Studio or your tool of choice.
Before deleting records from the [umbracoUser] table you heave to deal with related data in following tables:
We have three options here:
The SQL script below uses the second approach and is a good starting point:
BEGIN TRAN DECLARE @userId INT = ( SELECT id FROM [dbo].[umbracoUser] WHERE userLogin = 'email@example.com' ); UPDATE [dbo].[umbracoContentVersion] SET userId = NULL WHERE userId = @userId; UPDATE [dbo].[umbracoNode] SET nodeUser = NULL WHERE nodeUser = @userId; UPDATE [dbo].[umbracoLog] SET userId = NULL WHERE userId = @userId; DELETE FROM [dbo].[umbracoUser2UserGroup] WHERE userId = @userId; DELETE FROM [dbo].[umbracoUserLogin] WHERE userId = @userId; DELETE FROM [dbo].[umbracoUser2NodeNotify] WHERE userId = @userId; DELETE FROM [dbo].[umbracoUserStartNode] WHERE userId = @userId; DELETE FROM [dbo].[umbracoUser] WHERE id = @userId; ROLLBACK TRAN -- COMMIT TRAN
Once the SQL code is executed, the user should no longer show up in the Users section.
At this point, it's a good idea to run some basic system tests to make sure everything works as expected.
What about user-related content?
User related content will not display deleted author, but you should be able to restore previous versions of the content.
You can see it in the screenshot below:
As I wrote earlier, Umbraco allows you to hide inactive users in the back-office by changing the settings. To enable this feature, you need to locate the umbracoSettings.config file (~/config/umbracoSettings.config). Then, navigate to the security section and find a tag named "hideDisabledUsersInBackoffice".
As the name suggests, once you change the value to "true", inactive users should not be listed in the back office section.