I am trying to get the user_id for current logged in user in MyFile.php.
I have enabled php in ACP board security and added this to my template overall_footer:
Code: Select all
<!-- PHP -->
{
include 'MyFile.php';
MyFunction();
}
<!-- ENDPHP -->
However, when I try to get current user_id like this, then the output is just "User: " - because the last part getting user_id is null.
Code: Select all
function MyFunction()
{
echo 'User: '.$user->data['user_id'];
}
Code: Select all
function MyFunction()
{
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
echo 'User: '.$user->data['user_id'];
}