Create a user account via API (programmatically)

Permalink
I would like to use SSO to authenticate and register users on my concrete5 website. When a user successfully authenticates, an object is returned with various details about the user. I would like to create a user account with those details. How can I do this via API?

 
nebuleu replied on at Permalink Reply
nebuleu
You can use the add() static public method of Concrete\Core\User\UserInfo class :
http://concrete5.org/api/class-Concrete.Core.User.UserInfo.html#_ad...

Quick example :
use Concrete\Core\User\UserInfo;
UserInfo::add(array('uName' => 'John Doe', 'uEmail' => 'john.doe@example.com', 'uPassword' => '123456'));
surefyre replied on at Permalink Reply
surefyre
UserInfo::add seems to be deprecated now :o(

What's the new way of achieving this going forward?
Mnkras replied on at Permalink Reply
Mnkras
In v8 you do it like so:

$create = $this->app->make(RegistrationService::class);
$user = $create->create($data);


You can see the create method here:http://docs.mnkras.com/_registration_service_8php_source.html...

Mike
surefyre replied on at Permalink Reply
surefyre
Thanks for this. I solved it earlier this afternoon by piecing disparate posts together ending up with

$userRegistrationService = \Core::make('\Concrete\Core\User\RegistrationServiceInterface');
...
$userinfo = [ 'uName' => $username, 'uEmail' => $email, 'uPassword' => $pass ];
$reg = $userRegistrationService->create($userinfo);


But your above code is much less ugly.
surefyre replied on at Permalink Reply
surefyre
And how then to Validate/Activate the user account?