MyBB Community Forums

Full Version: Limit showthread in one forum to one group.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm trying to do a little edit to showthread.php to disallow thread viewing to ONE usergroup, but allow viewing on the forumdisplay by all. Any idea how to do this without a plugin?
You're better off doing it with a plugin. Core edits are messy and will make upgrading harder.

Regardless, this should work:

if(in_array($mybb->user['usergroup'], array(1,2)) && $mybb->input['fid'] == 73) {
    error_no_permission();
}

Just edit the array of usergroups to your liking.
(2012-11-21, 04:07 AM)Nathan Malcolm Wrote: [ -> ]You're better off doing it with a plugin. Core edits are messy and will make upgrading harder.

Regardless, this should work:

if(in_array($mybb->user['usergroup'], array(1,2)) && $mybb->input['fid'] == 73) {
    error_no_permission();
}

Just edit the array of usergroups to your liking.

Alright, can you point me to a working plugin for 1.6.8?
Thank you for your help. Smile
interested to know which plugin too. Big Grin
I don't believe there is one available. It's only a few lines of code. You just need to hook on to showthread_start and execute the above code in a function.
where in the code must i insert the lines and which usergroup is the guest?
(2012-11-21, 04:36 AM)enhu Wrote: [ -> ]where in the code must i insert the lines and which usergroup is the guest?

Added right behind this part:

$plugins->run_hooks("showthread_start");

Guests group id is 1.
I put this together, but it's not working. Any idea?

<?php

function nonsponsor_block_info()
{
	return array(
		"name"			=> "Non Sponsor Block",
		"description"	=> "Blocks premium tips and tricks to non sponsors.",
		"website"		=> "",
		"author"		=> "",
		"authorsite"	=> "",
		"version"		=> "1.0",
		"guid" 			=> "",
		"compatibility" => "1*"
	);
}

$plugins->add_hook('showthread_start', 'nonsponsor_block');
$plugins->add_hook('archive_thread_start', 'nonsponsor_block');

function nonsponsor_block() 
{
if(in_array($mybb->user['usergroup'], array(1,2,5,10,12,13,14,19,21,22,24)) && $mybb->input['fid'] == 73) {
    error_no_permission();
} 
}
?>
function nonsponsor_block() 
{
global $mybb;
if(in_array($mybb->user['usergroup'], array(1,2,5,10,12,13,14,19,21,22,24)) && $mybb->input['fid'] == 73) {
    error_no_permission();
} 
}
It still doesn't seem to be working, I don't know if I'm doing something wrong or what. I can provide a test account if you wish. Thanks for your efforts Nathan.
Pages: 1 2