Forums

Load user's info

studiocardo 07 Sep, 2014
Hi Bob

I want to trigger CF to send an email and display a message after a user submits a specific form. In this form, I added

<?php
$user =& JFactory::getUser();
$form->data['user_id'] = $user->id;
$form->data[`user_name`]=$user->name;
?>

in DB Read event during On Load. And I can see the right data are retrieved from the DB and place in the form array in the debugger message below:

Array
(
[user_id] => 938
[] => Front Desk
[Data] => Array
(
[id] => 937
[name] => Demo Demo
)

)

Per the FAQ, I was under the impression that this is sufficient and I can just access the field by using {user_name} in Display Message and Email. However, upon Submit, the debugger shows:

Array
(
[chronoform] => Username_test
[event] => submit
[user_name] =>
[button2] => Submit
)

And the user_name (a hidden field in the form w/ the name & ID of user_name) is blank. I am sure I did something wrong… Any pointer is much appreciated.

regards,
SH
Max_admin 07 Sep, 2014
1 Likes
Just use the same code inside a "custom code" action at the top of the "on submit" event, this is more secure:
<?php
$user =& JFactory::getUser();
$form->data['user_id'] = $user->id;
$form->data[`user_name`]=$user->name;
?>


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
studiocardo 08 Sep, 2014
Answer
Hi Max

I made a mistake in my code. ' vs `… Sigh. I appreciate your suggestion too! Thx!

SH
This topic is locked and no more replies can be posted.