• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Lack of interest Auto Thread Delete every X Days

James

Well-known member
#6
Perhaps. But is there need for such a feature? I probably wouldnt ever use this because I value my topics (except perhaps spam). It'd be more useful to just do a tutorial on how to set this up as a cron job
 

Jaxel

Well-known member
#7
Code:
public function deleteThreads()
{
	$deleteDate = strtotime('-365 days');

	$threads = $this->_getDb()->fetchAll("
		SELECT * FROM xf_thread
		WHERE last_post_date < ?
	", $deleteDate);

	foreach ($threads AS $thread)
	{
		$this->getModelFromCache('XenForo_Model_Thread')->deleteThread($thread['thread_id'], 'hard');
		XenForo_Helper_Cookie::clearIdFromCookie($thread['thread_id'], 'inlinemod_threads');
	}
}
This function will HARD delete all threads that haven't had a new post in over 365 days. Just add it to a cron.
 
R

ragtek

Guest
#8
PHP:
XenForo_Helper_Cookie::clearIdFromCookie($thread['thread_id'], 'inlinemod_threads');
C&P?:D
 

Decent60

Well-known member
#9
Perhaps. But is there need for such a feature? I probably wouldnt ever use this because I value my topics (except perhaps spam). It'd be more useful to just do a tutorial on how to set this up as a cron job
Topics that have become obsolete on my forum get pruned after x-amount of days from the last posting (well it did while were on vB :p). If this was section specific, it would be really nice as not all sections get an "obsolete" time frame.
 

Ajaxboy

Active member
#10
I think it is a bad idea, cause all that old good threads with lots of good info and search engine friendly would also get deleted. I think a simple addon should do it for you or a cron job.
 
#11
Code:
public function deleteThreads()
{
$deleteDate = strtotime('-365 days');

$threads = $this->_getDb()->fetchAll("
SELECT * FROM xf_thread
WHERE last_post_date < ?
", $deleteDate);

foreach ($threads AS $thread)
{
$this->getModelFromCache('XenForo_Model_Thread')->deleteThread($thread['thread_id'], 'hard');
XenForo_Helper_Cookie::clearIdFromCookie($thread['thread_id'], 'inlinemod_threads');
}
}
This function will HARD delete all threads that haven't had a new post in over 365 days. Just add it to a cron.
any clue how to make it forum specific?
Lets say for classified forums (and childs) so posts would be auto-deleted after 30 days ?