MyBB Community Forums

Full Version: how can i make a forums restriction for certain groups
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I working on a plugin and i have a few questions.

I have the code to redirect to another area (login area)
I take forums by id and usergroups by id.

The usergroups works fine, but when i have to go and take the forum id it does not work, i have four options on plugin.

1.- Forums by id where the mod works
2.- Groups id for users who does not view content and redirect to login page (this works fine)
3.- Time to redirect to another page
4.- What page is taken for redirection.

Only the forums by id not works, i take the hook

forumdisplay_thread

and on that way declare on global the var $forum

and i put a conditional like usergroups with the data

$forum['id']

But still not works, if i have a forum with the id on array this value make a response, but i have no idea how to. If someone has any idea i apreciate it.

Thanks in advice.
You don't define $forum as global(s) but $fid.

So after defining $fid, you could use something like:

if($mybb->user['usergroup'] == 2 && $fid == 7)
{
//Something done here would take place if the usergroup of user is Registered (2) and the forum id is 7 (as per above defined condition).
}
I probe the code and it works, but i make an array xD.


I make some probes today.



    $forum_fids = explode(',', $mybb->settings['forum_restrict_forums_active']);
    $forum_gids = explode(',', $mybb->settings['forum_restrict_gid_active']);  

if(in_array($mybb->user['usergroup'],$forum_gids) && in_array($fid,$forum_fids))
    {
	error("".$mybb->settings['forum_restrict_data_text']." <meta http-equiv='refresh' content='".$mybb->settings['forum_restrict_data_redirect'].";URL=member.php?action=login'>");

    }  


Thanks the code goes fine.

So many thanks now the mod goes fine xD, thank you.

Solved this task.