So I tried copy/pasting some stuff into a new .php file:
// Set up user handler.
require_once MYBB_ROOT."inc/datahandlers/user.php";
$userhandler = new UserDataHandler("insert");
// Set the data for the new user.
$user = array(
"username" => 'username123',
"password" => 'password123',
"password2" => 'password123',
"email" => '[email protected]',
"email2" => '[email protected]',
"usergroup" => 2,
"referrer" => '',
"timezone" => '0',
"regcheck1" => '',
"regcheck2" => 'true',
"registration" => true
);
$user['options'] = array(
"allownotices" => 1,
"hideemail" => 1,
"subscriptionmethod" => 2,
"receivepms" => 1,
"pmnotice" => 1,
"pmnotify" => 1,
"invisible" => 0,
"dstcorrection" => 0
);
$userhandler->set_data($user);
$errors = array();
if(!$userhandler->validate_user())
{
$errors = $userhandler->get_friendly_errors();
}
$userhandler->insert_user(); // didn't rly handle $errors here
http_response_code(200);
echo json_encode($errors);
But I don't get anything in the
mybb_users table... :\
Seems I was debugging this wrong.. also I was missing something from this to get
MYBB_ROOT
define("IN_MYBB", 1);
define("IGNORE_CLEAN_VARS", "sid");
define('THIS_SCRIPT', 'member.php');
define("ALLOWABLE_PAGE", "register,do_register,login,do_login,logout,lostpw,do_lostpw,activate,resendactivation,do_resendactivation,resetpassword,viewnotes");
require_once "./global.php";
I'm getting the error "The user is not valid."
Ok I got it working (I hope, stuff is showing up in the users table)
This was the final code... nothing really changed from above, and there's some junk in there but I'm taking a break lol
define("IN_MYBB", 1);
define("IGNORE_CLEAN_VARS", "sid");
define('THIS_SCRIPT', 'member.php');
define("ALLOWABLE_PAGE", "register,do_register,login,do_login,logout,lostpw,do_lostpw,activate,resendactivation,do_resendactivation,resetpassword,viewnotes");
require_once "./global.php";
// Set up user handler.
require_once MYBB_ROOT."inc/datahandlers/user.php";
$userhandler = new UserDataHandler("insert");
// Set the data for the new user.
$user = array(
"username" => 'username1234',
"password" => 'password123',
"password2" => 'password123',
"email" => '[email protected]',
"email2" => '[email protected]',
"usergroup" => 2,
"referrer" => '',
"timezone" => '0',
"regcheck1" => '',
"regcheck2" => 'true',
"registration" => true
);
$user['options'] = array(
"allownotices" => 1,
"hideemail" => 1,
"subscriptionmethod" => 2,
"receivepms" => 1,
"pmnotice" => 1,
"pmnotify" => 1,
"invisible" => 0,
"dstcorrection" => 0
);
$userhandler->set_data($user);
$errors = array();
if(!$userhandler->validate_user())
{
$errors = $userhandler->get_errors();
}
error_log("~".print_r($errors,TRUE),0);
$userhandler->insert_user(); // didn't rly handle $errors here
http_response_code(200);
$out = array_values($errors);
echo json_encode($errors);