• 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

No permission to download

Jake Bunce

XenForo moderator
Staff member
#1
Jake Bunce submitted a new resource:

Omit thread from recent activity (code example) (version 1.x) - Allows you to omit a thread from recent activity. Useful for spammy threads.

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 =...
Read more about this resource...
 

DRE

Well-known member
#4
Can you please create a version that will let you omit an entire subforum and the threads included inside?

This is for registered feeds.

http://xenforo.com/community/threads/news-reader.28610/

Okay I also found out putting the news bot on invisible and making it so no one can view their activity feed does work for most regular members but does not work for users who can bypass user privacy. Because of that, news bot posts will show up for them in recent activity.
 

Jake Bunce

XenForo moderator
Staff member
#5
Can you please create a version that will let you omit an entire subforum and the threads included inside?

This is for registered feeds.

http://xenforo.com/community/threads/news-reader.28610/
Here is code for you:

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);
	}
}
The node_id is specified twice, one for each content type (posts and threads).
 

Solidus

Well-known member
#11
It's not working for me. I have my thread ID in, but it still shows in recent activity page. "The chat thread"

PHP:
<?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'] == 45049)
            {
                return;
            }
        }

        parent::publish($userId, $username, $contentType, $contentId, $action, $extraData);
    }
}