Allow Null Username/Password Field

Dtorr1981 07 May, 2015
Hi Guys,

I am creating a lead capturing form which can be used on a promotional stand, thus am only looking to capture minimum details such as Name, Tel Number and Email address, and then create a user in the database, which we will then manage ourselves and update with additional information as and when required. The users will not be logging in to the site at all (well not these ones).

I have used the demo registration form and have limited the input fields to Name and Email (i will add the additional fields once i have this working). However, i am receiving:

You must provide your Username
You must provide your Password

Does anyone know how i can by pass this?
Dtorr1981 07 May, 2015
I am attempting some trial and error on this one, so here goes:

In my registration form i want to use First Name (fname) and Last Name (lname) instead of Name (name), thus i have used the following in my custom code in the On Success box of the joomla registration:

<?php
$form->data['name'] = "{$form->data['fname']} {$form->data['lname']}";
$form->data['username'] = "substr(md5(rand()), 0, 7){$form->data['lname']}";
$form->data['password'] = "substr(md5(rand()), 0, 7)";
$form->data['password2'] = $form->data['password'];
?>


But this doesnt seem to work (please excuse any code errors, im relatively new at this). I get Undefined Index lname and the same for fname prior to submitting the form, then still get the error 'You must provide your name/username/password' errors. Is there anyway to generate the name from what is entered in the lname and fname fields, then generate the username from the lname field plus some random characters, then again some random characters for the password field?

This form will only be available during promtions so will be disabled at all other times.

Best Regards
Donna
GreyHead 07 May, 2015
Hi Donna,

The quoting is broken in these two lines
$form->data['username'] = "substr(md5(rand()), 0, 7){$form->data['lname']}";
$form->data['password'] = "substr(md5(rand()), 0, 7)";
please try
$form->data['username'] = substr(md5(rand()), 0, 7).$form->data['lname'];
$form->data['password'] = substr(md5(rand()), 0, 7);

Bob
Dtorr1981 07 May, 2015
Thanks Bob, I'll just add this now and give it a go. Its been driving me nuts. If i wanted to automate the generation of the name field from the fname and lname field how would i go about joining the two with a space between them? Can i do similar to the above but put:

$form->data['name'] = $form->data['fname'].$form->data['lname'];


Best Regards
Donna
Dtorr1981 07 May, 2015

Thanks Bob, I'll just add this now and give it a go. Its been driving me nuts. If i wanted to automate the generation of the name field from the fname and lname field how would i go about joining the two with a space between them? Can i do similar to the above but put:

$form->data['name'] = $form->data['fname'].$form->data['lname'];


Best Regards
Donna



Just to confirm, the above code goes in a custom module? Where would i place the custom module in the setup? Im still having problems. I have gotten around the password issue using the autogenerate password option so all is good. I can assign the lname field to name and it populates it with the last name, (this is from within the joomla registration in setup) but the custom code does not seem to be loading?

Best Regards
Donna
Dtorr1981 07 May, 2015
Woohoo....I;ve figured that out now....so all is well. Now, i have an additional table which will store additional user information. I have read that i have to add a DB save and point it towards this table. No problem, however i am confused about Model ID's and how to connect the 2 tables. I've worked alot in Access DB's thus this is quite a bit different.

Thank you again for your help, i think i'll be buying you a coffee 😀
Dtorr1981 07 May, 2015
Again, i have managed to figure this out through digging around and some trial and error. For anyone that is struggling, If you add a custom code module after the joomla registration, then add the following:

<?php
$form->data['user_id'] = $form->data['_PLUGINS_']['joomla_registration']['id'];
?>


Then add your DB Save action, and select the additional table you want to Update/Append the user id from tbl_users will be saved in your new table.

Well, on to the next now🙂
This topic is locked and no more replies can be posted.