rtadams89 Posted December 9, 2008 Share Posted December 9, 2008 I have phpBB 3.0.3 installed and working great. I am trying to use the phpBB user data on other pages of my site (not phpBB related). For example, I have one page which I only want displayed to currently logged in forum members, who belong to the phpBB group #7 or #8. Here is the current code of that page: <?require($_SERVER['DOCUMENT_ROOT'].'/includes/functions.php');?> <? define('IN_PHPBB', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : $_SERVER['DOCUMENT_ROOT'].'/forum/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup(); $username = $user->data["username"]; $uid = $user->data["user_id"]; if (($user->data["is_registered"]) && (($user->data['group_id'] == || ($user->data['group_id'] == 7))){ $auth = 2; //Logged in as Coach/Officer } elseif (($user->data["is_registered"]) && ($user->data['group_id'] != && ($user->data['group_id'] != 7)){ $auth = 1; //Logged in as player } else{ $auth = 0; //Not logged in } if ($auth == 2) { //Display "secret" content here } ?> This works fine. However, I will be using the $auth variable on multiple pages. I would therefor like to place all of the above code in a function inside "functions.php" (included at the top of each page). I though I could just create a function like that: function phpbb_auth() { define('IN_PHPBB', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : $_SERVER['DOCUMENT_ROOT'].'/forum/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup(); $username = $user->data["username"]; $uid = $user->data["user_id"]; if (($user->data["is_registered"]) && (($user->data['group_id'] == || ($user->data['group_id'] == 7))){ $auth = 2; //Logged in as Coach/Officer } elseif (($user->data["is_registered"]) && ($user->data['group_id'] != && ($user->data['group_id'] != 7)){ $auth = 1; //Logged in as player } else{ $auth = 0; //Not logged in } return $auth; } and then place "phpbb_auth();" at the top of my content page. This always results in a 500 error when viewing the page. I don't know if the problem is in the way I Construct and call the function, or if it is a limitation of phpBB. Any help? Link to comment https://forums.phpfreaks.com/topic/136276-getting-phpbb-session-data-using-function/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.