XF 2.0 Delete all posts of a user

anon666

Active member
To remove all posts of a user with direct queries to the database, how do you build such queries to avoid breaking relationships between tables?

The new EEC privacy law has a section called "right to digital oblivion". In order to apply this "digital forgetfulness" to a user, what would be the queries to the database?

I believe that all IP addresses, private conversations, profile messages, and posts of the user in question should be deleted from the database.
 
The right to be forgotten does not include the complete deletion of all posts made by a user. There are plenty of discussions on this already, just check the GDPR discussion threads. At the most, only posts which have personally identifiable information would need to be deleted or edited. The vast majority, if not all, posts would not be personal information and so would not need to be removed.

Direct queries of the database are not recommended by the XenForo staff due to the various relationships between tables.
 
Surely that would have an impact on the threads that their posts were part of?
And if you have a prolific poster that deleted all their posts, a lot of threads would be disjointed
 
I agree it’s not a good idea, nor is it required by any law, but I think you can do this using the spam cleaner and just needs temporarily resetting the spam criteria then delete the user’s post as spam and it deletes all that user’s posts.

At your own risk.
 
Last edited:
I wouldn't delete any posts either. I would just change the user's name to anonymous or something. If you delete his posts in which he started a thread then all posts in that thread would be deleted as well. That's not fair as far as I'm concerned.
 
I agree it’s not a good idea, nor is it required by any law, but I think you can do this using the spam cleaner and just needs temporarily resetting the spam criteria then delete the user’s post as spam and it deletes all that user’s posts.

At your own risk.

Recently a user has asked me to delete all his posts, and he does me a favor because he only writes spam and floods.
The whole community gains if I delete all your posts and threads.
But the spam tool doesn't work for me with this user, and I don't understand it, it might have more than 5000 posts.

My spam settings are:

ACP > Setup > Options > Spam management > Spam cleaner user criteria:
  • Maximum message count = 0
  • Maximum days since registration = 0
  • Maximum likes received = 0
If any of these criteria are set to 0 (zero) they will be ignored.
 
I also tried to apply an @AndyB add-in to this user (Delete posts), I left this error message in his forum:

An exception occurred: [TypeError] Argument 2 passed to XF\Service\Post\Deleter::__construct() must be an instance of XF\Entity\Post, null given, called in .../src/XF/Container.php on line 274 in src/XF/Service/Post/Deleter.php on line 25

XF\Service\Post\Deleter->__construct() in src/XF/Container.php at line 274
XF\Container->createObject() in src/XF/App.php at line 1359
XF\App->XF\{closure}() in src/XF/Container.php at line 228
XF\Container->create() in src/XF/App.php at line 2508
XF\App->service() in src/addons/Andy/DeletePosts/Pub/Controller/DeletePosts.php at line 145
Andy\DeletePosts\Pub\Controller\DeletePosts->actionDelete() in src/XF/Mvc/Dispatcher.php at line 249
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 88
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 41
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1931
XF\App->run() in src/XF.php at line 328
XF::runApp() in index.php at line 13
 
Top Bottom