I have a script that creats a new Board username, please see code below.
The issue is that I am getting the
usernametaken error, this even happens on usernames that are not taken and that meet all requirements.
The strangest thing is that an account actually does get registered eventhough
$userdm->save(); does not get called.
Any help would be appretiated.
vBulletin Version 3.8.4
PHP Code:
<?php
function qpc_post($varname)
{
return trim(stripslashes((get_magic_quotes_gpc()) ? $_POST[$varname] : addslashes($_POST[$varname])));
}
define('THIS_SCRIPT', 'AddSBUser.php');
chdir('/path/to/board/');
require_once('./global.php');
require_once('./includes/class_dm.php');
require_once('./includes/class_dm_user.php');
$userdm = new vB_DataManager_User($vbulletin, ERRTYPE_ARRAY);
$userdm->set('username', qpc_post('username'));
$userdm->set('email', qpc_post('email'));
$userdm->set('password', qpc_post('password'));
$userdm->set('ipaddress', qpc_post('ipaddress'));
$userdm->set('usergroupid', 2); //Registered users have a groupid of 2.
$userdm->set_bitfield('options', 'adminemail', 1);
$ReturnString = '';
if (count($userdm->errors))
{
for ($i = 0; $i < count($userdm->errors); $i++)
{
$ReturnString .= "<li>ERROR {$i}:{$userdm->errors[$i]}</li>";
}
unset($userdm);
}
else
{
# If everything is OK save the data.
$newuserid = $userdm->save();
$ReturnString .= "<li>Account Created.</li>";
}
echo $ReturnString;