Hi all! I need to bother you again...
Following various guides, I created a registration form witch stores data in two different tables (eg. jos_users and jos_chronoforms_other_table).
Now I need a field (eg. country) in another form, to be filled in with a data stored in jos_chronoforms_other_table depending on logged in user.
I guess I have to write a query comparing id (jos_users) and cf_user_id (jos_chronoforms_other_table). I tried and tried but now i'm stuck with no solution...
Hoping someone could help me, thanks in advance.
Federico
Following various guides, I created a registration form witch stores data in two different tables (eg. jos_users and jos_chronoforms_other_table).
Now I need a field (eg. country) in another form, to be filled in with a data stored in jos_chronoforms_other_table depending on logged in user.
I guess I have to write a query comparing id (jos_users) and cf_user_id (jos_chronoforms_other_table). I tried and tried but now i'm stuck with no solution...
Hoping someone could help me, thanks in advance.
Federico
Hi Federico,
So the logged in user will choose the country through a dropdown ? if yes then why dont you store it at the same "other_table" ?
Cheers
Max
So the logged in user will choose the country through a dropdown ? if yes then why dont you store it at the same "other_table" ?
Cheers
Max
Hi Max!
No. I don't want the user to choose the country. The field must be filled in automatically.
I shared the registration data in two tables cause I needed to add some fields in the joomla registration form and i read on this guide http://forum.joomla.it/index.php/topic,89247.msg391144.html#msg391144 that it was the best way for adding fields in the registration form avoiding problems during joomla updates.
'Till now I've been able to get user data depending on the logged in user creating an hidden field and using this code
I wanna do the same thing but getting data from other_table.
If logged in user id (stored in jos_users) and cf_user_id (stored in other_table) match, i want my field (country) to be filled in with the correspondent value (country).
No. I don't want the user to choose the country. The field must be filled in automatically.
I shared the registration data in two tables cause I needed to add some fields in the joomla registration form and i read on this guide http://forum.joomla.it/index.php/topic,89247.msg391144.html#msg391144 that it was the best way for adding fields in the registration form avoiding problems during joomla updates.
'Till now I've been able to get user data depending on the logged in user creating an hidden field and using this code
<input value="<?php $user =& JFactory::getUser(); echo $user->name;?>" id="hidden_21" name="nome_ente" type="hidden" />.I wanna do the same thing but getting data from other_table.
If logged in user id (stored in jos_users) and cf_user_id (stored in other_table) match, i want my field (country) to be filled in with the correspondent value (country).
Nobody's got any idea?
Hi federico85,
You'll need to look up the User ID and then use that to look up their country:
Bob
You'll need to look up the User ID and then use that to look up their country:
<?php
if ( !$mainframe->isSite() ) { return; }
$country = '';
$user =& JFactory::getUser();
if ( $user->id ) {
// the user is logged in
$db =& JFactory::getDBO();
$query = "
SELECT `country`
FROM `#__other_table`
WHERE `user_id` = '".$user->id."' ;
";
$db->setQuery($query);
$country = $db->loadResult();
}
?>
. . .
<div>Country: <?php echo $country; ?></div> Bob
Hi Bob... I tried and your code works perfectly... Cool!
Thanks again!
Federico
Thanks again!
Federico
This topic is locked and no more replies can be posted.
