I am creating a form and would like to capture the user name and email. I thought I had the code but when I try to echo it to the screen both variables are blank. Below is the code. I am still trying to figure out both ChronoForms and PHP so it could be either one where I have a problem.
Thanks,
James
<?php
$user = &JFactory::getUser();
$useremail = $user->email;
$username = $user->name;
echo "user email is $useremail \r\n";
echo "user name is $username \r\n";
?>
Thanks,
James
Ok. Major mess up on my part. My user id had timed out so when I went to view it from the forms manager I was not logged in. When I log in, everything seems to work good. I am wanting to grab the name and put it in an email.
One more question. I am trying to put the user name in an email so I have the code shown above and add the following line
In the email template section, I add "{user_name} just completed the Survey". When I receive the email, all I see is "just completed the Survey", but I see the user->name echoed out from the previous code.
JRequest::setVar('user_name',$user->name);
. In the email template section, I add "{user_name} just completed the Survey". When I receive the email, all I see is "just completed the Survey", but I see the user->name echoed out from the previous code.
This topic is locked and no more replies can be posted.