1
I've used (for years) the following code to add programmatically a new user to xoops:
$newuser = $member_handler->createUser();
$newuser->setVar('user_viewemail',0, true);
$newuser->setVar('name',$name, true);
$newuser->setVar('uname', $mail, true);
$newuser->setVar('email', $mail, true);
$newuser->setVar('pass',md5($newpass), true);
$newuser->setVar('timezone_offset', $xoopsConfig['default_TZ'], true);
$newuser->setVar('user_regdate', time(), true);
$newuser->setVar('uorder',$xoopsConfig['com_order'], true);
$newuser->setVar('umode',$xoopsConfig['com_mode'], true);
$newuser->setVar('user_mailok',1, true);
$newuser->setVar('uorder',$xoopsConfig['com_order'], true);
$newuser->setVar('umode',$xoopsConfig['com_mode'], true);
$newuser->setVar('level', 1, true);
$newuser->setVar('user_avatar','blank.gif', true);
//$member_handler->insertUser($newuser);
if (! $member_handler->insertUser($newuser)) {
echo $newuser->getHtmlErrors();
} else {
...
}
It worked for year, but now (2.5.4) it fails:
Warning:Insert failed in method 'cleanVars' of object 'XoopsUser' in file /class/model/write.php at line 270
any hint?