I have quite a lot of custom coding and receive information from a 3rd party web service.
I would like to take this data and create modx web users - can this be done with the api?
So far I have installed the login module and attempted to pre-populate the register forms - but this only works for real people and requires a confirmation email.
I have a resource group and access policy working for those who do register with the login plugin but am ideally looking to process the new user request through the API, in ’native’ PHP
Any (sensible) suggestions will be very much appreciated
-
☆ A M B ☆
- 3,141 Posts
Sorry, Revo (Never worked with Evo)
I didn’t know evo had an API and thought it had died a death
-
☆ A M B ☆
- 24,524 Posts
...
I didn’t know evo had an API and thought it had died a death
Oooh, I used to wash my boys’ mouth out for saying things like that
Seriously, since Evo just got a new RC release (1.0.5 RC1) with some really nice new features, it’s very much still alive.
This should get you started:
This will give you a new user:
$user = $modx->newObject('modUser', array ('username'=>'MyUser'));
$user->save();
This will give you a user with some stuff in his or her profile:
$user = $modx->newObject('modUser', array ('username'=>'MyUser'));
$userProfile = $modx->newObject('modUserProfile');
$userProfile->set('fullname','My User');
$userProfile->set('email','[email protected]');
$success = $user->addOne($userProfile);
if ($success) {
$user->save();
return '<p>User object and profile created</p>';
} else {
return '<p>failed to add profile. User not saved.</p>';
}
what about passwords?
Or any documentation about adding new users so I don’t have to keep asking questions?
What’s been provided so far has been of great help - thanks!
Quote from: Northie at Jan 12, 2011, 04:00 AM
what about passwords?
Or any documentation about adding new users so I don’t have to keep asking questions?
What’s been provided so far has been of great help - thanks!
I think it’s:
$user->set('password',md5('somePassword'));
At the very bottom of the page here:
http://bobsguides.com/revolution-objects.html you’ll find the fields of the user object and the user profile object.