Hi All,
After some time searching for someone with the same problem, and found none, I would like to ask you guys, what’s wrong with this piece of code:
require_once '/home/vhosts/xxxx/subdomains/modx/httpdocs/config.core.php';
require_once MODX_CORE_PATH.'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
$modx->getService('error','error.modError');
$response = $modx->runProcessor('security/user/create',array(
'class_key' => 'modUser',
'username' => $credentials['username'],
'fullname' => $juser->name,
'email' => $juser->email,
'phone' => $juser->telnr ? $juser->telnr:'0612345678',
'newpassword' => TRUE,
'password' => 'Testing1989',
'passwordnotifymethod' => 'e'
));
if ($response->isError()) {
if ($response->hasFieldErrors()) {
$fieldErrors = $response->getAllErrors();
$errorMessage = implode("\n",$fieldErrors);
} else {
$errorMessage = 'An error occurred: '.$response->getMessage();
}
}
The error message keeps on saying I should provide a password. When I try to generate a password instead of giving the processor one, it succeeds, but then fails on $user->save() inside the processor. Your help would be appreciated!
Edit:
The problem on asking the password is solved by using these params:
$response = $modx->runProcessor('security/user/create',array(
'username' => $credentials['username'],
'fullname' => $juser->name,
'email' => $juser->email,
'phone' => $juser->telnr ? $juser->telnr:'0612345678',
'newpassword' => TRUE,
/* Changed theses params */
'specifiedpassword' => $credentials['password'],
'confirmpassword' => $credentials['password'],
/* End of change */
'passwordnotifymethod' => 'e'
));
Sadly, it still hangs at $user->save()..