Notifications
Clear all

wpForo 1.x.x [Closed] Cleaning up old posts & topics

5 Posts
2 Users
0 Reactions
1,578 Views
Posts: 3
Topic starter
(@erkkiat)
Active Member
Joined: 3 years ago

Hi all,

What a great forum software and so easy to install and use. I love it.

I was wondering if there is a way to purge older posts and topics, like over 2 years old etc. I'm worried about my storage plan and would like to make sure I will have a way to trim the database size when needed.

Thanks for any ideas!

-- Eki 

 

4 Replies
Posts: 3
Topic starter
(@erkkiat)
Active Member
Joined: 3 years ago

I should explain the background a bit. The forum centers around mental health, and users are discussing the feelings of the day, medication etc. The relevance of some of the topics decreases over time. The most valuable content is kept, but a periodical cleanup would be useful for cost optimization.

 

3 Replies
Chris
(@chris)
Joined: 3 years ago

Famed Member
Posts: 3627

Hi @erkkiat,

You can delete posts and topics by newest/oldest date from Dashboard > Forums > Moderation > Published, use the Created Column to sort them by created date.

Second way is that we can give you an SQL which you can use to remove the topics and post lets say which are older 1 year, but for the SQL we need more Rules to make it work correctly:

How old must be the topics/post.

Which topics must not be deleted. For example, those which are sticky or solved or private.

(@erkkiat)
Joined: 3 years ago

Active Member
Posts: 3

Hi @chris,

Excellent! I could store the SQL somewhere for future use. Let's say we want to keep the sticky and private ones written by user "abc". I can modify it accordingly, but it's good to see if there are references I need to consider.

-- Eki 

Chris
(@chris)
Joined: 3 years ago

Famed Member
Posts: 3627

@erkkiat,

This SQL deletes all Topics, posts, and post fields, which are older than xx date, and it excludes those which are sticky or private created by user 666(user id), those which are not private or sticky created by user 666 will be also deleted.

DELETE t, p, pm FROM `wp_wpforo_topics` t
	LEFT JOIN `wp_wpforo_posts` p ON p.`topicid` = t.`topicid`
	LEFT JOIN `wp_wpforo_postmeta` pm ON pm.`postid` = p.`postid`
	WHERE t.`created` < '2020-01-01 00:00:00'
	AND NOT ( t.`userid` = 666 AND (t.`private` = 1 OR t.`type` = 1 ) )