How to Delete Umbraco User Permanently
How to hard delete a Umbraco user?
As you may have already noticed, 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
[umbracoUser] table has dependencies on the following tables:
In order to delete a record from the user table, you should first delete or modify the records in the related tables.
The SQL script below provides 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
Umbraco allows not to list deactivated users in the back-office.
It is very easy to enable this option and it gives some flexibility.
To use this feature, you must set the appropriate configuration in ~/config/umbracoSettings.config file.
Inside umbracoSettngs.config you will find a security section with a tag named "hideDisabledUsersInBackoffice".
As the name suggests, after changing the value to "true", inactive users should not be listed in the back office section.