Creating a user from frontend

Hey there,

quick question: I want to create kirby users from the frontend. Works perfectly – except the fact that I need to be logged in to the panel. Otherwise the $site->user() function returns false, and therefore $site->user()->create($data) won’t work. Is there a workaround to this problem? I already thought about loading my default admin user (or maybe a dummy user), but I’m not sure if there are any problems?

Thanks for your help guys,

Jakob

It should be $site->users()->create()

http://getkirby.com/docs/cheatsheet/users/create

Try:

try {

  $user = $site->users()->create(array(
      …
  ));

} catch(Exception $e) {
  …
}

Oh my… yeah thanks guys. I only looked at the user() section, and found create() method in the core… but that one was too obvious :smiley: thank you a lot!