<p>It definitely does sound like a missing foreign key constraint issue.</p>
<p>The Craft 2 version of the Fix FKs plugin for Craft 3 still lives here: <a href="https://github.com/pixelandtonic/craft-fixfks" rel="nofollow noreferrer">https://github.com/pixelandtonic/craft-fixfks</a></p>
<p>I'd give that a whirl.</p>

CC BY-SA 4.0
2020-08-13T10:56:08.303Z
Thanks! I'll give it a bash.
Aravona
CC BY-SA 4.0
2020-08-13T14:55:09.573Z
Unfortunately I can't seem to get the above to work, there is not a json file for 2.9.2, and I get a 404 or craft exception error when trying to run (local machine) - any ideas? Possibly I've the files in the wrong place?
Aravona
CC BY-SA 4.0
2020-08-12T21:53:15.133Z
2020-08-12T21:53:15.133Z
Brad Bell
<p>From the admin, if I delete a user they disappear from the admin list but not from the <code>users</code> database table.</p>
<p>Looking through the code I can see <code>UsersService.php</code> has a function <code>deleteUser</code> which calls the <code>deleteElementById</code> from <code>ElementsService.php</code> - but it does not seem to actually remove the user from the main users table at all.</p>
<p>The version of craft in use has recently been updated to 2.9.2 following the Craft CMS guide and I've read there maybe Foreign Key issues in the database, but the fixes (plugins) seem to only be for Craft 3, and we are unable to upgrade at this time.</p>
<p>Also looked at &gt; <a href="https://craftcms.stackexchange.com/q/15393">Users not being deleted from the craft_users table?</a></p>
<p>But as this did not have a full answer and is not a fix for the CMS side of things it's not viable.</p>
<p>How can I determine 1) where the issue is, and 2) how to resolve it?</p>

<users><craft2><craft-pro><element>
Users not fully deleting from the database
# Users not fully deleting from the database

(Asked by: username_0 on 2020-08-10)

From the admin, if I delete a user they disappear from the admin list but not from the `users` database table.

Looking through the code I can see `UsersService.php` has a function `deleteUser` which calls the `deleteElementById` from `ElementsService.php` - but it does not seem to actually remove the user from the main users table at all.

The version of craft in use has recently been updated to 2.9.2 following the Craft CMS guide and I've read there maybe Foreign Key issues in the database, but the fixes (plugins) seem to only be for Craft 3, and we are unable to upgrade at this time.

Also looked at > [Users not being deleted from the craft\_users table?](https://craftcms.stackexchange.com/q/15393)

But as this did not have a full answer and is not a fix for the CMS side of things it's not viable.

How can I determine 1) where the issue is, and 2) how to resolve it?

**Tags:** users, craft2, craft-pro, element


---

## 1 answers

### Answer by username_1 on 2020-08-12. Score: 1

It definitely does sound like a missing foreign key constraint issue.

The Craft 2 version of the Fix FKs plugin for Craft 3 still lives here: <https://github.com/pixelandtonic/craft-fixfks>

I'd give that a whirl.

> **Comments:**
> **username_0**: Thanks! I'll give it a bash.  
> **username_0**: Unfortunately I can't seem to get the above to work, there is not a json file for 2.9.2, and I get a 404 or craft exception error when trying to run (local machine) - any ideas? Possibly I've the files in the wrong place?  

---

