Jump to content

[SOLVED] Joomla related - adding users manually


richrock

Recommended Posts

Hi all,

 

I'm creating a custom interface for a client who is using Joomla (1.0.13) and also Community Builder for user management.  I'm having a little trouble with the password/user login...

 

I've created the form with all the prerequisite data, and got MD5 to encode the password.  I am also aware that adding a user also requires inserts into various tables on the database, which I am sure I've accounted for.  But the new user created on the CP I've been creating cannot log in.  The insert code is below (sorry it's a bit of a mess, I haven't cleaned it up yet)...

 

if ($_POST['sourceadduser']) {

			// Results when adding the user to the system
			// DEVNOTE - this also includes some MD5 encryption that is not fully tested.

			// create results

			// for jos_users
			$page_source=$_POST['sourceadduser'];
			//$fullname=$_POST['fullname'];
			$name=$_POST['name'];
			$username=$_POST['username'];
			$email=$_POST['email'];
			$password=md5($_POST['password']);

			echo $password;


			// for comprofiler
			$firstname=$_POST['firstname'];
			$middlename=$_POST['middlename'];
			$lastname=$_POST['surname'];
			$company=$_POST['company'];
			$house=$_POST['house'];
			$street=$_POST['street'];
			$town=$_POST['town'];
			$state=$_POST['state'];
			$county=$_POST['county'];
			$postcode=$_POST['postcode'];	
			$telephone=$_POST['telephone'];

			// extra address if required
			// 15-04-08
			$secondhouse=$_POST['secondhouse'];
			$secondstreet=$_POST['secondstreet'];
			$secondtown=$_POST['secondtown'];
			$secondcity=$_POST['secondcity'];
			$secondstate=$_POST['secondstate'];
			$secondpost=$_POST['secondzip'];

			// DEV NOTE - we need to join first and last names for the name entry 
			// in jos_users (for CB compatibility)
			$spc = " ";
			$fullname = $firstname.$spc.$lastname;

			//build the user profile
			$query_adduser = "INSERT INTO jos_users (`name`,`username`,`password`,`email`,`usertype`,`block`,`sendEmail`,`gid`,`registerDate`,`lastvisitDate`) VALUES ('".$fullname."','".$username."','".$password."','".$email."','".Registered."','0','1','18',NOW(),NOW())";
			$result = mysql_query($query_adduser) or die(mysql_error());

			// return user id
			$uid=mysql_insert_id();

			echo $uid;

			// get the user number and display.
			echo "Client <strong>".$name."</strong> has been stored with a Client ID: <strong>", mysql_insert_id();
			echo "</strong>";				

			// insert user privileges to the database
			$query_acl_aro = "INSERT INTO `jos_core_acl_aro` (`section_value`,`value`,`order_value`,`name`,`hidden`) VALUES ('users','".$uid."','0','".$name."','0')";
			$result_acl_aro = mysql_query($query_acl_aro) or die(mysql_error());

			// get the aro_id and group id
			$aroid=mysql_insert_id();
			echo $aroid;

			// map the user to the system
			$query_acl_map = "INSERT INTO jos_core_acl_groups_aro_map (`group_id`,`aro_id`) VALUES ('18','".$aroid."')";
			$result_acl_map = mysql_query($query_acl_map) or die(mysql_error());

			// next, we build the community builder profile
			// UPDATED - now includes much of the additional 
			$queryprofile = "INSERT INTO `jos_comprofiler` (`id`,`user_id`,`firstname`,`middlename`,`lastname`,`company`,`cb_house`,`cb_street`,`cb_town`,`cb_city`,`cb_state`,`cb_postcode`,`cb_telephone`,`cb_secondhouse`,`cb_secondstreet`,`cb_secondtown`,`cb_secondcity`,`cb_secondstate`,`cb_secondpost`) VALUES ('".$uid."','".$uid."','".$firstname."','".$middlename."','".$lastname."','".$company."','".$house."','".$street."','".$town."','".$city."','".$state."','".$postcode."','".$telephone."','".$secondhouse."','".$secondstreet."','".$secondtown."','".$secondcity."','".$secondstate."','".$secondpost."')";
			$result_pro = mysql_query($queryprofile) or die(mysql_error());


			echo "<br>";

			// get the user number and display.
			echo "Client <strong>".$name."</strong> has been stored with a Client ID: <strong>", $aroid;
			echo "</strong>";


			// Make sure it's all worked
			echo $fullname;
			// display results
			echo $page_source."<br>";

			//endif
			}

 

Has anyone got any idea why these users are not able to login?  They show up ok in the database (using phpmyadmin) and even the password is md5'd, so that shouldn't be a problem...

 

Sure I'm missing something, but when you look at the same piece of code for hours on end, then you can always miss the obvious :-(

 

Rich

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.