fredbob Posted June 23, 2017 Share Posted June 23, 2017 Is it possible to create users from another ProcessWire instance. This is my code for a registration page, it creates the user, but doesn't update it with the username, password and email. I presume this is because $u is on the current page, and not in the instance, and when $u is saved its not updating it on the other instance. I can't figure it out, if anyone has any ideas thy would be greatly appreciated. <?php if ($input->post->submit) { $username = $sanitizer->username($input->post->username); $email = $sanitizer->email($input->post->email); $password = $input->post->password; echo $username; echo $email; $clientbp = new ProcessWire('/path/', 'http://domain.com'); $u = $clientbp->wire(new User()); $u->of(false); $u->name = $username; $u->email = $email; $u->pass = $password; $u->addRole("guest"); $u->save(); $u->of(true); } ?> <form action="./" accept-charset="UTF-8" autocomplete="off" method="post"> <input type="text" name="username" placeholder="Username"> <input type="text" name="email" placeholder="Email"> <input type="password" name="password" placeholder="Password"> <button type="submit" name="submit" value="register">Register</button> </form> Link to comment Share on other sites More sharing options...
BitPoet Posted July 14, 2017 Share Posted July 14, 2017 That's likely the reason. Using the generator method instead of the normal constructor to create the user object should work, though I haven't tested it: $u = $clientbp->users->newUser(); Link to comment Share on other sites More sharing options...
fredbob Posted November 24, 2017 Author Share Posted November 24, 2017 I left this for a while, and have just come back to it. @BitPoet That creates the user okay, but doesn't allow to change the name, email, pass etc (in my testing anyway), it just created the user with today's date and time. For anyone who is interested, this is my solution. $u = $pw2->wire(new User()); $u->of(false); $u->name = $username; $u->email = $email; $u->pass = $password; $u->addRole("client"); $u->admin_theme = ("AdminThemeUikit"); $u->save(); $u->of(true); Credit from 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now