Jump to content

Recommended Posts

Posted

Hello,

I'm trying to create a new user from the API, this is my code:

$u = $users->add($csvnome);
$u->save();

$u->of(false);
// $u->save();
$u->azienda = $csvazienda;
$u->pass = $csvpass;
$u->email = $csvemail;
$u->nome = $csvnome;
$u->save();

$u->addRole("utente");
$u->save();  
$u->of(true);


I get this error: Error:     Exception: Can't save page 0: : Pages of type NullPage are not
saveable (in /Users/utente/Sites/gammapw/wire/core/Pages.php line 514)

I suppose this is not the right way to create a new user?

Thanks!!

Posted

Actually either syntax should work here. The $users->add('name'); function is a valid way to create a new user. Though the $u->of(); and $u->save(); immediately after your add() aren't necessary. The $users->add() syntax is newer though, so may not be present in past versions of PW. 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...