---
# System prepended metadata

title: What really happens when a user account is deleted?

---

# What really happens when a user account is deleted?

> **Does deleting a user account affect data profiles created/edited by that user?**

Deleting the user doesn't affect the data profiles that were created or have been edited by that user. The data profile has a `creator_user_id` field that stores a plain text value of the user id in the `user.id` column of the user table.

> **Does deleting a user account affect organizations created by the user?**

Deleting the user doesn't affect the organizaion that were created or have been edited by that user.

> **What happens in the database to the email used by a deleted account?**

When the user is deleted, the **`state`** field of the user in the database changes from **`active`** to **`deleted`** but all other details are left.
You can change the user back to an **`active`** state by using the **`user_update`** API.
Call the API: ***`/api/3/action/user_update?id=<user_id>&state=active`*** and pass the API key of an existing sysadmin in the `X-CKAN-API-Key` or `Authorization` header and that would set the user state back to active.

You cannot create another user with the same email or username while the user is deleted, but you can change the username and email if you need to use it for another user account.

> **When I delete an account I expect: The data items (data profile, data explorers, organizations, sources, etc) created by that user should remain on the system and in the same state (visible, hidden, approval queue status, etc) as they were before**

Deleting a user doesn't affect any of the data profile, data explorers, organizations, sources, etc that they had created.

## Other observations

* When a user is deleted, the api tokens generated by that user would no longer work.

## Why the user should NOT be manually deleted from the DB

If the user is manually deleted from the `public.user` table in the db, it doesn't break anything else. However, some other tables reference the `user_id` and if the user has rows in them referencing it, they would need to be deleted. Since the aim is to keep all the things the user created, it's best not to purge the user from the database but the details of the user such as the email and user name can be changed.

These are the tables referencing the user id:
* **`api_token`**
* **`dashboard`**
* **`package_member`**
* **`rating`**
* **`showcase_admin`**
* **`user_following_dataset`**
* **`user_following_group`**
* **`user_following_user`**
* **`user_following_user`**
