Resource icon

Omit thread from recent activity (code example) 1.x

No permission to download
It will prevent any new feed entries being made for a thread.

You need to edit this file to specify the thread_id you want to omit:

library/OmitFromRecentActivity/NewsFeedModel.php

Rich (BB code):
<?php

class OmitFromRecentActivity_NewsFeedModel extends XFCP_OmitFromRecentActivity_NewsFeedModel
{
	public function publish($userId, $username, $contentType, $contentId, $action, array $extraData = null)
	{
		if ($contentType == 'post')
		{
			$postModel = XenForo_Model::create('XenForo_Model_Post');
			$post = $postModel->getPostById($contentId);

			if ($post['thread_id'] == 81)
			{
				return;
			}
		}

		parent::publish($userId, $username, $contentType, $contentId, $action, $extraData);
	}
}
To specify multiple thread_ids use this code:

library/OmitFromRecentActivity/NewsFeedModel.php

Rich (BB code):
<?php

class OmitFromRecentActivity_NewsFeedModel extends XFCP_OmitFromRecentActivity_NewsFeedModel
{
	public function publish($userId, $username, $contentType, $contentId, $action, array $extraData = null)
	{
		if ($contentType == 'post')
		{
			$postModel = XenForo_Model::create('XenForo_Model_Post');
			$post = $postModel->getPostById($contentId);

			if (in_array($post['thread_id'], array(81,90,154)))
			{
				return;
			}
		}

		parent::publish($userId, $username, $contentType, $contentId, $action, $extraData);
	}
}
Here is code to omit an entire forum. You need to check two content types in this case, posts and threads:

library/OmitFromRecentActivity/NewsFeedModel.php

Rich (BB code):
<?php

class OmitFromRecentActivity_NewsFeedModel extends XFCP_OmitFromRecentActivity_NewsFeedModel
{
	public function publish($userId, $username, $contentType, $contentId, $action, array $extraData = null)
	{
		if ($contentType == 'post')
		{
			$postModel = XenForo_Model::create('XenForo_Model_Post');
			$post = $postModel->getPostById($contentId, array(
				'join' => XenForo_Model_Post::FETCH_THREAD
			));

			if ($post['node_id'] == 18)
			{
				return;
			}
		}
		else if ($contentType == 'thread')
		{
			$threadModel = XenForo_Model::create('XenForo_Model_Thread');
			$thread = $threadModel->getThreadById($contentId);

			if ($thread['node_id'] == 18)
			{
				return;
			}
		}

		parent::publish($userId, $username, $contentType, $contentId, $action, $extraData);
	}
}
Reactions: sbj
Author
Jake Bunce
Downloads
33
First release
Last update
Rating
5.00 star(s) 1 ratings

More resources from Jake Bunce

Latest reviews

i needed this for a forum and jake delivered!
Top