MyBB Community Forums

Full Version: [Plugin] Allow ONLY one user to browse a forum
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This plugin blocks the access to any user who wants to browse a specific forum.
It requires 2 very simple code modifications.
It is useful if you want to keep data on your site that you dont want to share with anyone.

IN ADMIN/MODULES/CONFIG/SETTINGS.PHP

FIND
// Change settings for a specified group.
if($mybb->input['action'] == "change")
{

BELOW ADD:
	if ($mybb->user['uid'] != 1 && $mybb->input['gid'] == 42)
	{
		flash_message("Error: you do not have permissions to edit this setting", 'error');
		admin_redirect("index.php?module=config/settings");
	}

CHANGE "42" (WITHOUT QUOTES) TO THE GROUP ID OF THIS PLUGIN. (The group ID can be found in settings, place the mouse over "Allow user to browse forum by Pirata Nervo" and you should see the url on the bottom. the Group ID is the &gid=NUMBER HERE.
This part of the code allows only the user #1 to edit the settings of this plugin.

IN FORUMDISPLAY.PHP

FIND
$plugins->run_hooks("forumdisplay_start");

$fid = intval($mybb->input['fid']);

ADD BELOW:
if ($mybb->settings['allowuser_uid'] > 0 && $mybb->settings['allowuser_fid'] > 0)
{
	if ($mybb->user['uid'] != $mybb->settings['allowuser_uid'] && $fid == $mybb->settings['allowuser_fid'])
	{
		error_no_permission();
	}
}

This part of the code blocks the access to every user (except the one specified in the settings).

If anything is wrong with the plugin please tell me.

[Download: Allow User 0.1]