Forums

(SOLVED...Partly)How to pass cf_uid in url

gabedaly 09 Jun, 2011
I have a form for customers to register. It saves to the database both CF and Joomla. I also made a login form with CF and all is working well. But this my issue, I need my customers to be able to go to another form after logging in to view and pay their bill. How exactly do I get the logged in users info passed on to the "record loader" so it can load only their data from the database? Thank you!
GreyHead 10 Jun, 2011
Hi gabedaly,

You can use the ReDirect URL action (in the cURL Group) to build a url including the values you want to pass.

You could also save the data to the User Session and use a plain URL in the ReDirect User action.

Bob
gabedaly 11 Jun, 2011
Thanks Bob.
I can do this with a session and a redirect, but how do I set it up so when a registered user logs in via a simple username/password form then they can navigate around the site a little before going to the "paybill" or similar type of form?

Will a session grab their cf_id from a simple login form and store it until they are ready to fill out another form? If so, that would be great because then I can set up the DB record loader to auto populate the fields for them but I don't know how to do this from a login form. I can only get it to work with a redirect of some sorts.

If the session can't grab the cf_id from the login form, how can I can make this work?

Thanks, Gabe
GreyHead 11 Jun, 2011
Hi Gabe,

If they are logged in then you can always get their id from the Joomla! User Object
<?php
$user =& JFactory::getUser();
$user->id // << will give you the current user's id
. . .

Bob

PS Search here on 'getUser' for many, many examples.
gabedaly 11 Jun, 2011
Wow that was quick reply! Bob, where do I put this code?
GreyHead 11 Jun, 2011
Hi Gabe,

Anywhere you can use PHP and need to have the User ID.

Bob
gabedaly 11 Jun, 2011
Can you be more specific please? Sorry but I'm not sure where I can put php in CF.
GreyHead 11 Jun, 2011
Hi Gabe,

You can use PHP in pretty much any of the Code boxes - that is the textareas in the action configuration dialogues.

Bob
gabedaly 12 Jun, 2011
Here is the code to place in the WHERE box of the DB Record Loader:

<?php
$user = &JFactory::getUser();
echo "cf_user_id = ".$user->id
?>

IT WORKS!!!
gabedaly 12 Jun, 2011
I know I have to topics that are similar, sorry. Please feel free to delete one of them.

Here is an issue I came across. When setting this up I have the joomla registration event setting auto login set to yes. If I set it to no then the cf_user_id is recorded as 0 and I can not display any DB info. How can I set the auto login to NO so I can send an activation email and still get the correct cf_user_id from the Joomla id?

Here is the code I am using in the WHERE box of the DB Loader:

<?php
$user = &JFactory::getUser();
echo "cf_user_id = ".$user->id
?>
This topic is locked and no more replies can be posted.