Add user in joomla from outside
#############Created By Rahul Dev Sharma ###################
#### Insert user into joomla data base from out side #######
############################################################
include('affut_org_connect.php');
$name = $first_name. " ".$middle_name. " " .$last_name;
$queryForInsertInMicrosite = "insert into `jos_users` set `name` = '".$name. "',
`username` = '".$email_address."',
`email` = '".$email_address."',
`password` = '".md5($password)."',
`usertype` = 'Registered',
`block` = '0',
`sendEmail` = '1',
`gid` = '18',
`registerDate` = '".date('Y-m-d h:i:s')."',
`lastvisitDate` = '".date('Y-m-d h:i:s')."',
`activation` = ''";
if(mysql_query($queryForInsertInMicrosite))
{
// insert into jos_core_acl_aro
$insert_user_id = mysql_insert_id();
$queryForInsertInto2Table = "INSERT INTO `jos_core_acl_aro` SET `section_value` = 'user' , `value` = '".$insert_user_id."', `name` = '".$name."', `hidden` ='0'";
if(mysql_query($queryForInsertInto2Table))
{
$aro_id = mysql_insert_id();
// insert into `jos_core_acl_groups_aro_map` table
$queryForInsertInto3Table = "INSERT INTO `jos_core_acl_groups_aro_map` SET `group_id` = '18' , `aro_id` = '".$aro_id."'";
if(!mysql_query($queryForInsertInto3Table))
{
mysql_query("DELETE FROM `jos_core_acl_aro` WHERE `id` = '".$aro_id."'");
}
}
else
{
mysql_query("DELETE FROM `jos_users` WHERE `id` = '".$insert_user_id."'");
}
}