We\'re creating an XML API for Joomla that allows partner sites to create new accounts for their users on our website.
We\'ve created a standalone PHP script that
Just go to documentation page: http://docs.joomla.org/JUser
Also competed sample of single page to register new users in Joomla:
get( 'new_usertype' );
if (!$usertype) {
$usertype = 'Registered';
}
// set up the "main" user information
//original logic of name creation
//$data['name'] = $firstname.' '.$lastname; // add first- and lastname
$data['name'] = $firstname.$lastname; // add first- and lastname
$data['username'] = $username; // add username
$data['email'] = $email; // add email
$data['gid'] = $acl->get_group_id( '', $usertype, 'ARO' ); // generate the gid from the usertype
/* no need to add the usertype, it will be generated automaticaly from the gid */
$data['password'] = $password; // set the password
$data['password2'] = $password; // confirm the password
$data['sendEmail'] = 1; // should the user receive system mails?
/* Now we can decide, if the user will need an activation */
$useractivation = $usersParams->get( 'useractivation' ); // in this example, we load the config-setting
if ($useractivation == 1) { // yeah we want an activation
jimport('joomla.user.helper'); // include libraries/user/helper.php
$data['block'] = 1; // block the User
$data['activation'] =JUtility::getHash( JUserHelper::genRandomPassword() ); // set activation hash (don't forget to send an activation email)
}
else { // no we need no activation
$data['block'] = 1; // don't block the user
}
if (!$user->bind($data)) { // now bind the data to the JUser Object, if it not works....
JError::raiseWarning('', JText::_( $user->getError())); // ...raise an Warning
return false; // if you're in a method/function return false
}
if (!$user->save()) { // if the user is NOT saved...
JError::raiseWarning('', JText::_( $user->getError())); // ...raise an Warning
return false; // if you're in a method/function return false
}
return $user; // else return the new JUser object
}
$email = JRequest::getVar('email');
$password = JRequest::getVar('password');
//echo 'User registration...'.'
';
register_user($email, $password);
//echo '
'.'User registration is completed'.'
';
?>
Please note that for registration used only email and password.
The sample of call: localhost/joomla/test-reg-user-php?email=test02@test.com&password=pass or just create simple form with appropriate parameters