Colbydude
New member
Hey all, I'm having a bit of trouble trying to register a user by external means.
I'm currently using the class posted in this thread: http://xenforo.com/community/threads/how-to-create-a-bridge.28515/#post-332676, trying to use the createUser function.
Exact function:
I'm currently running it using:
Just a simple call using some values after a form has been posted, for testing purposes.
However I'm getting the following error:
What I find to be a little confusing is that it's saying that "user_id" doesn't have a default value. But isn't this supposed to be creating a new "user_id" for the created user? Or am I not understanding this correctly?
Any information on this would be great, thanks.
I'm currently using the class posted in this thread: http://xenforo.com/community/threads/how-to-create-a-bridge.28515/#post-332676, trying to use the createUser function.
Exact function:
PHP:
public static function createUser($sUsername, $sEmail, $sPassword, array $aAdditionalData = array())
{
// Create the username from the person's name.
$sUsername = str_replace(' ', "_", $sUsername);
// Set User Data.
$cWriter = XenForo_DataWriter::create('XenForo_DataWriter_User');
$cWriter->set('username', $sUsername);
$cWriter->set('email', $sEmail);
$cWriter->setPassword($sPassword);
$cWriter->set('user_group_id', XenForo_Model_User::$defaultRegisteredGroupId);
$cWriter->set('user_state', 'email_confirm');
foreach ($aAdditionalData AS $data => $key)
{
$cWriter->set($data, $key);
}
$cWriter->save();
$cUser = $cWriter->getMergedData();
// Login new user: Log the ip of the user registering.
XenForo_Model_Ip::log($cUser['user_id'], 'user', $cUser['user_id'], 'register');
// Set the user back to the browser session.
XenForo_Application::get('session')->changeUserId($cUser['user_id']);
XenForo_Visitor::setup($cUser['user_id']);
return $cUser['user_id'];
}
I'm currently running it using:
PHP:
// Create the XenForo User.
$user_id = $xenApp->createUser($_POST["USERNAME"], $_POST["EMAIL"], $_POST["PASSWORD"], array("dob_day"=>$_POST["DAY"], "dob_month"=>$_POST["MONTH"], "dob_year"=>$_POST["YEAR"]));
Just a simple call using some values after a form has been posted, for testing purposes.
However I'm getting the following error:
An exception occurred: Mysqli statement execute error : Field 'user_id' doesn't have a default value in /home/<removed>/public_html/forum/library/Zend/Db/Statement/Mysqli.php on line 214
- Zend_Db_Statement_Mysqli->_execute() in /home/<removed>/public_html/forum/library/Zend/Db/Statement.php at line 317
- Zend_Db_Statement->execute() in /home/<removed>/public_html/forum/library/Zend/Db/Adapter/Abstract.php at line 479
- Zend_Db_Adapter_Abstract->query() in /home/<removed>/public_html/forum/library/Zend/Db/Adapter/Abstract.phpat line 574
- Zend_Db_Adapter_Abstract->insert() in /home/<removed>/public_html/forum/library/XenForo/DataWriter.php at line1612
- XenForo_DataWriter->_insert() in /home/<removed>/public_html/forum/library/XenForo/DataWriter.php at line 1601
- XenForo_DataWriter->_save() in /home/<removed>/public_html/forum/library/XenForo/DataWriter.php at line 1393
- XenForo_DataWriter->save() in /home/<removed>/public_html/authoring/includes/xenforo_app.php at line 190
- appXenForo::createUser() in /home/<removed>/public_html/authoring/minecraft/pages/register.php at line 69
- include() in /home/<removed>/public_html/authoring/minecraft/index.php at line 43
What I find to be a little confusing is that it's saying that "user_id" doesn't have a default value. But isn't this supposed to be creating a new "user_id" for the created user? Or am I not understanding this correctly?
Any information on this would be great, thanks.