سؤال

I want to add bridge between my PHP website and my PhpBB3 forum, so that when user login in my website then he automatically logged-in into PHPBB forum or when he sign-up in my site then he automatically signed-up in Forum. I have seen many article about it but not able to find the correct one which can solve my problem.

هل كانت مفيدة؟

المحلول

You can use the session that the PHPBB forum uses for this integration.

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : '/var/www/clients/client9/web8/web/forums/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include_once($phpbb_root_path . 'common.' . $phpEx);

$user->session_begin();

From here, you can use the $user object for your integration. For example, the code below will show you if your user is logged in or not.

if ($user->data['username'] == 'Anonymous')
{
    echo 'Please login!';
}

This uses the Anonymous user for validation, which PHPBB adds as the first user account when it is installed.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top