MyBB Community Forums

Full Version: Force Login Except on Portal.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want guests to only be able to see the portal page. I assume this is going to be a php edit. I am fluent in PHP but dont have the time to dig through everything to find the file that i need to edit. Mostly just need to know what file handles the force login enforcement.
I have only tested this somewhat on my test board, so there might be issues somewhere. However I did find this to work and still allow users to login. I however did not test registration.

global.php find:
// If the board forces user to login/register, and the user is a guest, show the force login message
if($mybb->settings['forcelogin'] == 1 && $mybb->user['uid'] == 0 && !in_array($current_page, $force_bypass) && (!is_array($force_bypass[$current_page]) || !in_array($mybb->get_input('action'), $force_bypass[$current_page])))
{
	// Show error
	error_no_permission();
	exit;
}

right below add:
// Guests cannot see anything but the Portal page.
if($mybb->user['uid'] == 0 && $current_page != 'portal.php' && !in_array($current_page, $force_bypass) && (!is_array($force_bypass[$current_page]) || !in_array($mybb->get_input('action'), $force_bypass[$current_page]))) {
	error_no_permission();
	exit;
}