Load & display table in form

ingenious1 31 Aug, 2011
Hi,

I have been searching on these forums for quite a while but I have been unable to get an answer.

I have 2 forms. The first form is used to enter a member's details to create an account. The form is saved in a field called UserRegistration. A joomla user account is also created.

I then have a second form made using CF, which is used to enter values and calculate a total price. This form will only be made available to logged in users. Hence I would like to load the appropriate record based on the user which is logged in.

I have found that you need to use the following code:
<?php
$user = &JFactory::getUser();
echo "cf_user_id = ".$user->id
?>


This gets the current logged in user's joomla details. I need this to find the appropriate record in the first form, then in the second form get data from it.

Any help is much appreciated
GreyHead 31 Aug, 2011
Hi ingenious1,

Which version of ChronoForms are you using? You can find the version from Site Admin | Extensions | Install/Uninstall | Components in Joomla! 1.5 or Site Admin | Extensions | Extension Manager | Manage in Joomla! 1.6.

Bob

PS I have a document you can buy here that describes theis process for CFv3.
ingenious1 31 Aug, 2011
I am using CF version 4.0 RC1.9 & Joomla 1.5.
GreyHead 31 Aug, 2011
Hi ingenious1,

The the DB Record Load action should do what you need.

Bob
ingenious1 31 Aug, 2011
Hi,

What I assume i need is a way to link the Joomla user account to the record created in the form. Is there a way to set one of the CF id's to the Joomla ID upon registration?

That way when i obtain the id of the current logged in user, I can use that to search in my table. I hope I am being clear.

Thanks!
GreyHead 31 Aug, 2011
Hi ingenious1,

I think that if you add this code in a Custom code action before the DB Record Loader:
<?php
$user =& JFactory::getUser();
JRequest::setVar('user_id', $user->id);
?>

Then you should be able to use iser_id as the Request Param in the DB Record Loader.

Bob
ingenious1 31 Aug, 2011
Hi,

It seems to be working. The problem is that when I fill in the registration form, which in turn creates a joomla account, the field cf_user_id is 0.

I have tried to set the cf_user_id to the joomla id through custom code or by using a hidden field in the form wizard.

I have tried to add a new hidden box, named "joomla_id", and set its value to the joomla id by setting the default value to <?php echo $user->id; ?> but i got the following error:
Notice: Undefined variable: .... Notice: Trying to get property of non-object

Any way I can do this? (I.e assign the value of the joomla id to "joomla_id" field to save it in the table?
Thanks
GreyHead 31 Aug, 2011
Hi ingenious1,

I'm sorry, you've lost me completely :-(

Bob
apryl 05 Oct, 2011
I think I am trying to do something similar and I can't quite get it to work.
I am redoing a site in 1.7 for a swim club. already have membership details for the members but need them to update their membership info once they are registered to the new site.
An email will be sent asking if they want to renew their membership.
If they choose yes link, they are redirected to the "registration" form.

Once registration is successful I need to redirect to the "membership info" form which I have used the DB Record Loader on.

I already have most of the membership info in the database for the form, but we have added fields for children's ages and emergency contacts, etc.. By using a hidden field for cf_id, cf_uid, and cf_modified. The record is saved over the existing one in the database and is working like I want.

My problem is in loading the proper record to the "membership info" form. I am not sure how to use info from the registration form (token?).

In the "membership info" form I have a field for Member Number (memno), or I thought about using email address since it would be unique. It would seem easy to use cf_uid, but since the member hasn't registered yet there is no value in my membership info database for cf_uid yet.

I would love to buy you a beer!

update: I have added the redirect URL and redirect User to the On Success box of my registration form. Redirect works, but wrong record loads.
GreyHead 06 Oct, 2011
Hi apryl,

I'm a great believer in random text strings for identifiers, you can use them safely in all kind sof places where user-ids are too easily guessed.

I'd add a column to your existing member table and use a little temporary form to add a unique random string like e.g. 'xay84e' to each row (a different one for each row!).

Then you can add this to the URL in the invitation email and when the link is clicked use it as the token to load the existing data into the form.

Once they have a suer id you should also add this into the member info form to link the two together.,

Bob
apryl 07 Oct, 2011
Hi Bob

I have created a registration form that will be emailed and added a field for the user's club membership number (memno) for a unique text string since all membership numbers are unique and the members know their own numbers.
In the Membership Info form I want to populate I also have the field "memno" as a read only field that already exists in the table.
After I save the registration to the the table I created for registration I have put in a custom code event:
 <?php
    $mainframe =& JFactory::getApplication();
    $form_url = "index.php?option=com_chronoforms&chronoform=memberProfile";
    $mainframe->redirect($form_url."&token=".$form->data['chronoform_data']['memno']);
    ?>

This works great and opens the proper record for the user to edit. I have included a hidden field "cf_id" and the record overwrites the existing one. Once they edit and submit I would like them to be able to access the form as needed from a menu link.

This is where I am now having problems. Even though the record is overwritten I am not getting any values for cf_uid or cf_user_id and I am not sure how to use "memo" as a variable in a menu link, or load some custom code before the "show html" event that will load the proper record.

Since the user has filled out the registration form they now have a cf_uid and cf_user_id that shows up in my table connected to my registration form.

How do I get these values to populate in the table connected to my Membership Info form?
Here is a screenshot of my Membership form table. Ignore Records 1-8 those were for testing
[attachment=1]dataSS.jpg[/attachment]
And Here is a copy of my table for registration which has the cf_uid and cf_user_id
[attachment=0]regDataSS.jpg[/attachment]

Your help is greatly appreciated,
Apryl
This topic is locked and no more replies can be posted.