MyBB Community Forums

Full Version: Merging Old User Database into MyBB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have been searching the forums for a solution to this issue, and found the incredibly useful MyBB Integrator class on GitHub.

My issue is that I wish to, upon a user logging in on the main website, migrate said user to the MyBB database. However, upon logging in, and calling the createUser function, the user is not generated in the MyBB user database.

<?php
    define('IN_MYBB', NULL);
    require_once './Forums/global.php';
    require_once './class/.MyBBIntegrator.php';
    $MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config);

    session_start();
    require 'password_compat/lib/password.php';
    include '/db_connect.php';

    ... //Other code to handle login

    if(!$migrated_to_mybb == 1)
    {
        $pass = $_POST['password']
        $email = mysql_fetch_array(mysql_query("SELECT email FROM table_name WHERE username = '$username'"))['email'];
        $info = array(
            "username" => $username,
            "password" => $pass,
            "password2" => $pass,
            "email" => $email,
            "email2" => $email,
            "usergroup" => 5,
            "additionalgroups" => "",
            "displaygroup" => 5,
            "regdate" => (strtotime(mysql_fetch_array(mysql_query("SELECT date_created FROM table_name WHERE username = '$username'"))['date_created']) * 1000)
        );
        $MyBBI->createUser($info);
    }

    ... //Other code to handle login

?>

Is there a way to fix this? Perhaps even a better way to handle migration of users from the first database to the MyBB one?