Skip Navigation

[Resolved] Data created by users not deleting when deleting user records

This support ticket is created 2 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#2333675

Hi Support

As part of our user registration process (clicking either Become a Native Nanny or Sign Up in menu), a new user record is created with First Name, Last Name and email address using a Toolset User Form. The user is then redirected to login and then, once logged in, to create either a Nanny record or a Family record via a Toolset Post Form (Post types Nanny and Family).

We have noticed while developing and testing that deleting those users is not deleting all content created by them.

For example, we have had to perform multiple "clean-ups" where we delete content to remove redundant test data from the database. When we delete those users from the database, we are prompted to either delete all content from the user or to assign it to another user. We always choose delete all content from the user, but we still have to go into the Nanny or Family post types and delete the redundant items there too.

The posts are only related via the post author relationship as far as I know, so in my opinion ALL content created by that user should be deleted. Why is this not the case?

You're welcome to follow the process of becoming a Nanny or registering as a family to test it for yourself in our dev environment to reproduce the issue.

Kind regards
Simon

#2334075

Hi Simon,

Thank you for contacting us and I'd be happy to assist.

I've tested this on your website and I had different results.

1. I used the respective front-end forms to create a test family and a test nanny user.
( screenshot: hidden link )

2. Next, I used the respective front-end forms to create a family and a nanny profile for those test users.
( screenshot family profile: hidden link )
( screenshot nanny profile: hidden link )

3. After that, I deleted both these users from the admin area, and selected the option to delete all the content for the user being deleted. As a result, not only the user but also the respective family/nanny profile post were deleted from the website. Even the uploaded files from those users in the media library were removed.

I'll recommend testing the process and confirm the same again, on your end.

regards,
Waqar

#2334145

Hi Waqar

Thank you for the update, however this issue in no way as urgent as our issue with messaging which you are also working on. I would very grateful if you could focus your time on working that messaging issue to resolution first. You wanted to provide an update by end of day yesterday. Did you run into further issues?

Regarding this issue, I still see the post IDs remaining from your tests from this morning when clicking on Nannies or Families post types in the back end:

Family:
post ID 22904 - the profile pic gets deleted, I concur, but the record with post ID 22904 is still there.

Nanny:
post ID 22911 - the profile pic gets deleted, I concur, but the record with post ID 22911 is still there.

Thanks and best regards
Simon

#2336781

Thank you for waiting.

I've done some testing and research and found that when a user is deleted, WordPress would only delete his/her posts if that post type is set to support the "author" attribute.

Please go to WP Admin -> Toolset -> Post Types and edit the post types "Families" and "Nannies". Under "Sections to display when editing" enable the option "Author" and these posts will be considered for deletion.
( you can repeat that for any other post types that you'd like to be covered for deletion )

#2337593

Hi Waqar

We tested this in the meantime with a new Nanny user and a new Family user. Everything gets deleted except for the standard WordPress Comments. Going to WP Admin > Toolset > Post Types, I don't see Comments, but am presuming it is running somehow under the standard post type Posts.

However for post type Posts, under the section "Sections to display when editing", it is saying "These options are not available for built-in post types."

Have you any tricks up your sleeve how we can delete the comments as well on User deletion? 😜

Thanks and regards
Simon

#2339625

I've performed some tests and research and can confirm that WordPress by design, doesn't delete the user's comments on user deletion.

You can follow the suggestions and code examples from these threads to implement this operation:
https://wordpress.stackexchange.com/questions/219065/delete-all-user-comments
https://wordpress.stackexchange.com/questions/73999/remove-the-deleted-user-comment

#2339841

OK, thanks for the confirmation.

As I found from my own research it can get messy if user's have created comments and other users have replied to those comments etc. Never run a changing system, eh? 😄

My issue is resolved now. Thank you!