Forums

CB & Virtuemart Registration

abemedia 18 Nov, 2009
Hi!

I'm currently building a website using Chronoforms to handle the signup. For Community Builder everything is working, but I also need to populate the Virtuemart tables.

I have so far managed to populate the first_name, last_name & user_email fields, however I still need to fill the user_id and user_info_id and since this is created by the register plugin and not taken from one of the fields I'm kinda stuck.

Can anyone help?

I was also thinking of putting a step by step tutorial together for this as I'm sure there's more users out there with the same problem!

Thanks

By the way I forgot to mention I'm using the newest versions of Joomla, CB, Virtuemart & Chronoforms.
GreyHead 18 Nov, 2009
Hi abemedia,

You should be able to pick up the new user_id from the Joomla User object after the registration.

I've no idea what the user_info_id is though.

Bob
abemedia 18 Nov, 2009
Thanks for the quick reply!

I've been experimenting and the only thing I actually need for this to work is the user_id field so don't worry about the other one...

I'm not entirely sure what you mean... Where in Chronoforms would I have to set this?


Cheers
abemedia 19 Nov, 2009
Hi!

I managed to get the user_id fields synchronised by simply setting the field in the vm_user_info to auto increment.

After searching through various forums I managed to find out how to get user_info_id generated.
But if I have the field for user_info_id in the form for some reason the form doesn't save anything to the database anymore.

Here's the code:
<input type="hidden" name="user_info_id" id="user_info_id" value="<?php echo md5( uniqid(_VIRTUEMART_SECRET )); ?>" />


When viewing the generated code on the front end it looks fine:
<input type="hidden" name="user_info_id" id="user_info_id" value="6c2b8c0276c02d0c0d9ab4eac6b1ae20" />


When I deleted the field it worked again but I need the field to be populated.
Any ideas how else I could write this to the database?

Thanks
GreyHead 19 Nov, 2009
Hi Adam,

The autoincrement solution will only work as long as no-one **ever** registers in any other way. Not a robust answer. Search here for getUser for the code to get the Joomla User object and find the current user_Id.

No idea why having a value for that field would stop the form saving unless it somehow creates an SQL command the has an errro ro execution. To check, set the Site Debug ON, submit the form and check the long list of debug code - usually at the foot of the page - to find the SQL command that is generated and check this for errors.

Bob
abemedia 25 Nov, 2009
I've managed to solve my problem!
Instead of using the table connection function on Chronoforms I just put following code in the onSubmit code:
<?
$MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id);
$db = JFactory::getDBO();

// Now add fields 
$query = sprintf('INSERT INTO jos_vm_user_info (`user_id`, `user_info_id`, `first_name`, `last_name`, `user_email`) VALUES (%s, %s, %s, %s, %s)',
    $db->Quote($MyPlugins->cf_cb_registration['user']->id),
    $db->Quote(md5( uniqid(_VIRTUEMART_SECRET ))),
    $db->Quote(JRequest::getString('first_name')),
    $db->Quote(JRequest::getString('last_name')),
    $db->Quote(JRequest::getString('user_email'))
);
$db->setQuery($query);
$db->query();


Thanks for your help mate!
This topic is locked and no more replies can be posted.