2 Forums, Single Login?
#1
Is there any way to have

1. a user who logs into forum1 automatically logged into forum2? (and vice versa)

2. if they register for forum1 they are registered with forum2? (and vice versa)

3. If they update the password/email , it updates on both
Reply
#2
That's mean U wana use SSO, U can use portal system (like joomla with bridger).
or:
Use table user with same prefix, but different prefix other table. Finally, You must change some line of code about connect to database (ex: $db->simple_select, update ...). You must use only one domain (subdomain1, subdomain2)=> SSO here (because proplem of web explode), cookie domain = .forum.com (forum 1 domain: forum1.forum.com, ...)
Other way, you can study about ucenter system (discuz forum), it will use <script src="http://forum1.domain.com/connect.php?k=[code single sign on]"></script> it will set cookie cross domain ([code single sign on] must be encoded).
for item 2, 3: you can use curl & connect it to http://forum1.domain.com/connect.php?k=[code command]. other way, U can use XML-RPC (I like IXR lib, it very easy).
U must write a plugin and add_hook (on change password, on register, etc...)

// I'm vietnamese, I'm styding English :p
Forum MyBB VietNamese
mybb's vietnamese
Reply
#3
Thanks for the reply! So could you explain how to use the SSO here:
http://community.mybb.com/thread-118986.html

For 2 mybb forums

Currently it's for mybb and a CMS
Reply
#4
(2012-07-26, 09:45 PM)mobert Wrote: Is there any way to have

1. a user who logs into forum1 automatically logged into forum2? (and vice versa)

2. if they register for forum1 they are registered with forum2? (and vice versa)

3. If they update the password/email , it updates on both

Hi mobert,

Download the MyBBIntegrator constructor here: http://phpdave.com/MyBBIntegrator/, this is a great script because it has basically everything you'd need to integrate your mybb with your front site ready and done.

So, I'm generous today, and I'll share my codes that I've spent time building, so I hope you'll be glad for it.

Login:
<?php
define('IN_MYBB', NULL);
global $mybb, $lang, $query, $db, $cache, $plugins, $displaygroupfields;
require_once '/path/to/mybb_forum/global.php';
require_once '/path/to/MyBBIntegrator.php';
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config);

$login_status = $MyBBI->login($_POST['username'], $_POST['password']);
if ($login_status == true) echo 'Logged in successfully';
else echo 'The login routine failed';
?>

Registration:
<?php
define('IN_MYBB', NULL);
global $mybb, $lang, $query, $db, $cache, $plugins, $displaygroupfields;
require_once '/path/to/mybb_forum/global.php';
require_once '/path/to/MyBBIntegrator.php';
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config);

$info = array(
    'username' => $_POST['username'],
    'password' => $_POST['password'],
    'password2' => $_POST['password_confirm'],
    'email' => $_POST['email'],
    'email2' => $_POST['email'],
    'hideemail' => 1,
    'allownotices' => 1,
    'emailpmnotify' => 1,
    'invisible' => 0,
    'receivepms' => 1
);

$register_status = $MyBBI->register($info);

// Array means: registering failed
if (is_array($register_status))
{
    echo implode('<br />', $register_status);
}
else
{
    echo $register_status;
}
?>

Update password: (You must adjust the $_POST['newpassword'] after your html form input, you should use the same field name "<input name=" FIELD NAME " />" as you do in your POST variable.

<?php
define('IN_MYBB', NULL);
global $mybb, $lang, $query, $db, $cache, $plugins, $displaygroupfields;
require_once '/path/to/mybb_forum/global.php';
require_once '/path/to/MyBBIntegrator.php';
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config);

$myupdatepass = $MyBBI->updatePasswordOfUser($MyBBI->mybb->user['uid'], $_POST['newpassword']);
if ($myupdatepass === true)
{
    echo 'Password updated';
}
else
{
    echo $myupdatepass;
}
?>

Update email:
<?php
define('IN_MYBB', NULL);
global $mybb, $lang, $query, $db, $cache, $plugins, $displaygroupfields;
require_once '/path/to/mybb_forum/global.php';
require_once '/path/to/MyBBIntegrator.php';
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config);

/* You must change the $yourusernamevariable to whatever your system uses, most common are $user, $username or $uname. */

$username = $yourusernamevariable;
$email = $_POST['email'];

$db->update_query("users", $email, "uid='".$yourusername."'", 1);
$plugins->run_hooks('password_changed');
?>

If you find them helpful, please give me reputation for it, I'd be more than happy Wink
Give me reputation if you find my replies helpful

MODx, I'd recommend you to use it, you'll save time in your development.
Reply
#5
You know I have given this a little thought and "multisite" sounds like a good challenge. It would be possible through a plugin.

You could just use the login hooks to run a function that checks the the credentials against another database or table, you may even just be able to have the tables in the same database with a different prefix.

You would then also need your plugin to hook into any change in usercp or user details and as well as the registration so you could push the data to the other forum when the registration is complete.

I am writing some integrations stuff with Joomla and wordpress so some of the work will be done within the plugin I write, so you will be able to adapt that, or if I am feeling especially enthusiastic I will write you some code that will do most of what you want. However you will need to give me some time to get around to that.

I actually think a multisite plugin would be a decent idea and certainly think they need their own tables, we wouldn't want two busy sites in the one posts table and hit the 4m row limit
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)