MyBB Community Forums

Full Version: How to remove soft deleted post?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Is there any option by which we can remove permanently all soft deleted post or any sql query?
hi
DELETE FROM `mybb_posts` WHERE `visible` = '-1'
(2021-07-17, 06:33 PM)Mostafa.Shiraali Wrote: [ -> ]hi
DELETE FROM `mybb_posts` WHERE `visible` = '-1'

thank you but it didnot work for me, any help please?

https://i.imgur.com/wUx1FYg.png

however if i try to visit the thread i get error "specific thread is not available"
Numeric field: DELETE FROM mybb_posts WHERE visible=-1
it's same, may be cache issue? thread is not available for restore. only in section it's showing. board statistics also showing correct.

https://i.imgur.com/JNhe63b.png
Ok, so this is not posts but threads.

You can delete unapproved (and/or soft deleted) threads using delete from mybb_threads where visible=-1.

You can also delete threads where first post have been deleted using delete from mybb_threads where not exists (select null from mybb_posts p where p.pid=firstpost)

As alway, think to backup your database before using these queries
delete from mybb_threads where visible=-1 it's working fine, but the thread sql still staying in phpmyadmin

https://i.imgur.com/eY4jIDX.png
This is the mybb_posts table, it's normal that the previous query doesn't affect it.
So, do delete from mybb_posts where visible=-1 to remove the posts.
thank you worked fine. however there is an another issue.

there is a thread and reply in that thread. i made soft delete thread. run your sql command thread is deleted but the reply post is still in sql database. is there anyway we can delete those as well?

many many thanks for helping me out.

is there anyway we can auto remove soft delete thread+post after X days?
You can use Purge soft deleted posts and threads

If you want to purge soft deleted threads, you must use a more complex query:
delete t, p from mybb_threads t left join mybb_posts p on p.tid=t.tid where t.visible=-1

Think to save your database before applying this query, I didn't verify it
Pages: 1 2