MyBB Community Forums

Full Version: A modification to JammerX2's "Guests can't view threads" script.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
<?php
$plugins->add_hook('showthread_start', 'gcvt_thread');
$plugins->add_hook('archive_thread_start', 'gcvt_thread');

function gcvt_info()
{
	return array(
		'name'			=> 'Guests Can\'t View Threads',
		'description'	=> 'Guests cannot view threads.',
		'website'		=> 'http://mybbplug.in/',
		'author'		=> 'Jammerx2',
		'authorsite'	=> 'http://mybbplug.in/',
		'version'		=> '1.1',
		'guid'        => '8ac34edb831b6a420c48602ed5384b59'
	);
}

function gcvt_activate()
{
}

function gcvt_deactivate()
{
}
function gcvt_thread()
{
	global $db, $mybb,$lang, $thread;

                	if($mybb->user['uid'] == 0)
                	{
                    	error("I'm afraid I cannot let you view that! Guest thread viewing is disabled, but why not sign up and join-in on the fun? We're not that scary, are we?","Error");
                	}
					
	$lang->send_thread = "";
}
?>
http://mybbplug.in/s/thread-guests-can-t-view-threads-1-1

I'm currently using Jammerx2's "Guests Can't View Threads" script on my forum and I was wondering if anyone would mind adding a few simple functions for me.

I'd like to make it so that un-activated users (group ID 5) get a different message when they try to view threads and also make it so that posts in forum IDs 11, 28 and 29 are exempt from the effects of the script.

Could anyone give me a hand please? I'm not sure how hard this is to do
In the code above, find;
function gcvt_thread()
{
    global $db, $mybb,$lang, $thread;

                    if($mybb->user['uid'] == 0)
                    {
                        error("I'm afraid I cannot let you view that! Guest thread viewing is disabled, but why not sign up and join-in on the fun? We're not that scary, are we?","Error");
                    }
                    
    $lang->send_thread = "";
}

and Replace it with;
function gcvt_thread()
{
    global $db, $mybb,$lang, $thread, $fid;
$forums = array(11,28,29);
                    if($mybb->user['uid'] == 0 && !in_array($fid,$forums))
                    {
                        error("I'm afraid I cannot let you view that! Guest thread viewing is disabled, but why not sign up and join-in on the fun? We're not that scary, are we?","Error");
                    }
elseif ($mybb->user['usergroup'] == "5" && !in_array($fid,$forums))
{
   error("A_NEW_CUSTOM_ERROR_MESSAGE.", "Error");
}
                    
    $lang->send_thread = "";
}

Replace A_NEW_CUSTOM_ERROR_MESSAGE. with your own text. Wink
Thanks mate, worked a charm!
ThankYou.