MyBB Community Forums

Full Version: External login script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have the following problem:
I have a site and a MyBB forum. In the site there is a login/registration form. How can I make this: when someone logs in the site to log him automatically in the forum? And also when someone registers in the site to automaatically register a user with the same usernam,email,password in the fourm?
(2012-07-29, 02:46 PM)paranoiks Wrote: [ -> ]I have the following problem:
I have a site and a MyBB forum. In the site there is a login/registration form. How can I make this: when someone logs in the site to log him automatically in the forum? And also when someone registers in the site to automaatically register a user with the same usernam,email,password in the fourm?

Hi paranoiks,

To begin with, go visit http://phpdave.com/MyBBIntegrator/, and download the constructor, this script has finished functions built upon the mybb core functions. You can easily use the constructor for login, logout and registrations.

As for the login function, here's a little bit of code that I use myself:

<?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;
}
?>

Hope you found them helpful!
its not that simple to do all of this which is why birdges are few and far between.

I am writing one at the moment for Joomla and mybb and once complete and tested I will be writing the same thing for mybb and wordpress.

Its difficult to write a generic system, in fact its not really possible, but you can adapt them.

Do you use a CMS and if so which one, if i have the time I will see if I can write one for you when I am done with wordpress.
(2012-08-01, 01:25 PM)Dannymh Wrote: [ -> ]its not that simple to do all of this which is why birdges are few and far between.

I am writing one at the moment for Joomla and mybb and once complete and tested I will be writing the same thing for mybb and wordpress.

Its difficult to write a generic system, in fact its not really possible, but you can adapt them.

Do you use a CMS and if so which one, if i have the time I will see if I can write one for you when I am done with wordpress.

Actually, I don't see any difference in making a bridge for mybb and some cms, the biggest problem is interest and time in development.

If you got some imagination and creativity, then it shouldn't be a bigger problem.
What I was stating is you cant write a generic one size fits all, you need to know the db classes and other things.
Likewise the mybbintegrator from phpdave, whilst helpful is useless with Wordpress and joomla because of class conflicts in mybb and those cms.

Writing your own bridge can be done but it's certainly no simple task. In fact I can't see the point in your last reply, it adds nothing to the ops question
(2012-08-01, 09:33 PM)Dannymh Wrote: [ -> ]What I was stating is you cant write a generic one size fits all, you need to know the db classes and other things.
Likewise the mybbintegrator from phpdave, whilst helpful is useless with Wordpress and joomla because of class conflicts in mybb and those cms.

Writing your own bridge can be done but it's certainly no simple task. In fact I can't see the point in your last reply, it adds nothing to the ops question

Actually, you don't need to know every core handler in mybb to create a bridge, you just use basic mysql queries and update statements to update data in the tables.

PS: If you want a CMS that has system event handling, easy controller processing and really extensible possibilities then go for MODx (It's a Content management platform), it won't interfere with any bridge or code (trust me), it's built upon the powerful mysql PDO extension. You should check it out, http://en.wikipedia.org/wiki/MODX http://www.modx.com

After you've used it for some weeks or months, then tell me what you can't do in MODx.

Joomla and WordPress is far behind MODx when it comes to successive development in mysql and php, Joomla is also known as the most vurnerable CMS, WordPress isn't that good either. With MODx you can easily make a blog system.
I have used modx before its just another cms really. I currently use joomla on a large site and as much as I think they have lost their way a little, it really is a fantastic content delivery system.

You are still completely and utterly missing the point by the way.
(2012-08-02, 11:14 AM)Dannymh Wrote: [ -> ]I have used modx before its just another cms really. I currently use joomla on a large site and as much as I think they have lost their way a little, it really is a fantastic content delivery system.

You are still completely and utterly missing the point by the way.

MODx is for those who got creativity and imagination. With Joomla there are numerous limits for what you can do and not.