Thank you for you answer. I looked to the Adsmanager code to find the function which creates the user account when an ad is posted.
This is just a data injection query in the comprofile table. (administrator/components/com_adsmanager/models/user.php)
Code:
function saveRegistration($comprofiler) {
// If user registration is not allowed, show 403 not authorized.
$params = JComponentHelper::getParams('com_users');
if ($params->get('allowUserRegistration') == '0') {
echo "Error: allowRegistration set to Off in Joomla.";
exit();
}
if (version_compare(JVERSION,'1.6.0','<')) {
$authorize = JFactory::getACL();
$user = clone(JFactory::getUser());
// Initialize new usertype setting
$newUsertype = $params->get( 'new_usertype' );
if (!$newUsertype) {
$newUsertype = 'Registered';
}
// Bind the post array to the user object
$post = JRequest::get('post');
$post['username'] = $post['username'];
$post['password2'] = $post['password'];
if (!$user->bind($post, 'usertype' )) {
JError::raiseError( 500, $user->getError());
}
// Set some initial user values
$user->set('id', 0);
$user->set('usertype', $newUsertype);
$user->set('gid', $authorize->get_group_id( '', $newUsertype, 'ARO' ));
$date = JFactory::getDate();
$user->set('registerDate', $date->toMySQL());
// If user activation is turned on, we need to set the activation information
$useractivation = $params->get( 'useractivation' );
if ($useractivation == '1')
{
jimport('joomla.user.helper');
$user->set('activation', JUtility::getHash( JUserHelper::genRandomPassword()) );
//$user->set('block', '1');
}
// If there was an error with registration, set the message and display form
if ( !$user->save() )
{
JError::raiseWarning('', JText::_( $user->getError()));
return false;
}
} else {
// Initialise the table with JUser.
$user = new JUser;
$data = JRequest::get('post');
//HACK OUTROUVER
//$data['username'] = $data['email'];
// Prepare the data for the user object.
$useractivation = $params->get('useractivation');
// Check if the user needs to activate their account.
if (($useractivation == 1) || ($useractivation == 2)) {
jimport('joomla.user.helper');
if (version_compare(JVERSION,'3.0.3','>=')) {
$data['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
} else {
$data['activation'] = JUtility::getHash(JUserHelper::genRandomPassword());
}
//$data['block'] = 1;
}
// Get the groups the user should be added to after registration.
$data['groups'] = array();
// Get the default new user group, Registered if not specified.
$system = $params->get('new_usertype', 2);
$data['groups'][] = $system;
// Bind the data.
if (!$user->bind($data)) {
$this->setError(JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError()));
return false;
}
// Load the users plugin group.
JPluginHelper::importPlugin('user');
// Store the data.
if (!$user->save()) {
$this->setError(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $user->getError()));
return false;
}
}
$post = JRequest::get('post');
$username = $post['username'];
//HACK OUTROUVER
//$username = $post['email'];
$this->_db->setQuery( 'SELECT `id`'
. ' FROM `#__users`'
. ' WHERE username=' . $this->_db->Quote( $username ));
$userid = (int)$this->_db->loadResult();
if ($comprofiler > 0)
{
$data = new stdClass();
$data->id = $userid;
$data->user_id = $userid;
$data->lastname = JRequest::getVar('name', "" );
$data->firstname = JRequest::getVar('firstname', "" );
$data->middlename = JRequest::getVar('middlename', "" );
[b] //HACK OUTROUVER[/b]
/*$data->cb_civilite= JRequest::getVar('cb_civilite', "" );
$data->cb_companyname= JRequest::getVar('cb_companyname', "" );
$data->cb_siren= JRequest::getVar('cb_siren', "" );
$data->cb_tel= JRequest::getVar('cb_tel', "" );
$data->cb_profiletype = JRequest::getVar('cb_profiletype','');//professionnel,particulier
*/
$this->_db->setQuery("SELECT count(*) FROM #__comprofiler WHERE id = $userid");
$result = $this->_db->loadResult();
if ($result)
$this->_db->updateObject('#__comprofiler', $data,'id');
else
$this->_db->insertObject('#__comprofiler', $data);
}
return $userid;
}