MyBB Community Forums

Full Version: Guest group cannot view threads with [--] in the title
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there any way something like this could be made? Basically what I would like is a plugin that prevents guests from viewing any thread that contains [--] (or any two letters really; [TW][MA][PG] etc) that can be specified by the admin.
Open the file showthread.php in your MyBB root.

Find

// Show the entire thread (taking into account pagination).
if($mybb->input['action'] == "thread")
{

Underneath this code after the curly brace, add this

if($mybb->user['uid'] == 0)
	{
		// Prevent guests from viewing threads which subjects contain words found in this array
		$denied_titles = array(
			'[MA]',
			'[TW]',
			'[PG]'
		);

		foreach ($denied_titles as $t)
		{
			if (strstr($thread['subject'], $t) !== false)
			{
				error('Guests are not permitted to view threads with ' . $t . ' in the subject. Please Register to view this thread.');
			}
		}
	}
...and the same for newreply, printthread, archive, possibly syndication, ... might have forgotten some
Basically by thread prefixes.