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

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

Allows you to omit a thread from recent activity. Useful for spammy threads.

  1. Jake Bunce
    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

    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

    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

    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);
    	}
    }
    
    sbj likes this.

Recent Reviews

  1. DRE
    DRE
    5/5,
    Version: 1.x
    i needed this for a forum and jake delivered!