How to Delete Umbraco User Permanently
Table of contents
How to hard delete a Umbraco user?
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.
For various reasons such as GPDR, deactivating users may not be a sufficient solution.
How to remove the Umbraco user 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 an 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.
Umbraco user delete SQL script
In order to delete a record from the [umbracoUser] table, you should first delete or modify the records in the related tables:
The SQL script below is a good starting point:
BEGIN TRAN DECLARE @userId INT = ( SELECT id FROM [dbo].[umbracoUser] WHERE userLogin = 'firstname.lastname@example.org' ); 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
Optional instead of setting userId = null you can just set system user id: userId = -1.
In this case, all user-related elements will be assigned to the system user.
It's good to wrap SQL code with the transaction to avoid data integrity issues when something goes wrong.
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 is working 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:
How to hide disabled users in Backoffice
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.