MyBB Community Forums

Full Version: Logged in cookie.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey. I want to add pages to my forum. But I need to check if the user is logged in and only let certain user groups in.
I know php and all but I don't know any of the cookie/session names. Does anyone know them?
You can do this:

if(!in_array($mybb->user['usergroup'], array("2", "3", "4", "6"))
{
//this user isn't a member, mod/supermod or admin...
error_no_permission();
}
else
{
//this user IS a member, mod/supermod or admin, so put the code for the page here...
echo "Hello!! :)";
}
Just checking Who is online is not sufficient?
do I put the usergroups I want in where it says usergroup. And do I need to include any files
Oh, yeah, sorry, you'll need this at the start:

define("IN_MYBB", 1);
require "global.php";

And then put the GIDs of the usergroups you want to allow into the array, like the others.
I just get a blank page. How to I find out the id's. Can I do it without going into the database?
Add another ) to the end of the first line of the code in post #2 and change error_no_permission; to error_no_permission();

Final code should be this:

<?php
define("IN_MYBB", 1);
require "global.php";
if(!in_array($mybb->user['usergroup'], array("2", "3", "4", "6")))
{
	//this user isn't a member, mod/supermod or admin...
	error_no_permission();
}
else
{
	//this user IS a member, mod/supermod or admin, so put the code for the page here...
	echo "Hello!! :)";
}
?>

Sorry about the errors, my fault Toungue

You can find the GIDs by editing a usergroup in the ACP, the GID will be at the end of the URL.