Following the guide: $users->create() | Kirby CMS
In my case emails are optional, so email is often “”. In Kirby 2 this worked without any problems.
In Kirby 4 i always get an exception when I create a user, even when I try to exclude the “email” property like so:
if(filter_var($file->arr["Student"]["Email"], FILTER_VALIDATE_EMAIL)){
$user = $kirby->users()->create(array(
'name' => $file->arr["Student"]["Username"],
'email' => $file->arr["Student"]["Email"],
'password' => $passwort,
'language' => 'de',
'role' => "client",
'content' => [
'firstName' => $file->arr["Student"]["Vorname"],
'lastName' => $file->arr["Student"]["Nachname"],
'jahrgang' => $file->arr["Student"]["Jahrgang"],
] ));
}else {
$user = $kirby->users()->create(array(
'name' => $file->arr["Student"]["Username"],
'password' => $passwort,
'language' => 'de',
'role' => "client",
'content' => [
'firstName' => $file->arr["Student"]["Vorname"],
'lastName' => $file->arr["Student"]["Nachname"],
'jahrgang' => $file->arr["Student"]["Jahrgang"],
]
));
}
Email seems strictly required. Is there a solution for this?
In addition, the login seems to work only with the e-mail address as username and no longer with the account name? - That was different with Kirby 2 - or can the behaviour be configured somewhere?