Lets pretend you need some user information from a logged in user in your form. But you don't want to have the user type in his user info again and again, because he already did it while registering for the Account.
So you are looking for a possibility to automatically fill in the users name, username, e-mail adress into the chronoform, so the user doesn't have to type it again.
Here's the (easy!) solution with a little bit help of the Joomla Framework:
Enter (or copy & paste) the following code at the beginning of your chronoform HTML-Code:
- Code: Select all
<?php
// Get user-information from Joomla
$user = &JFactory::getUser();
?>
In the form itself use the following syntax to fill either inputboxes or hidden fields with the wanted user information like that:
Fill the user info into an inputbox:
- Code: Select all
<input type="text" name="username" id="username" size="20"
maxlength="40" value="<?= $user->name; ?>" />
The "value"-tag and the following snippet of php will insert the username ($user->name) into the text field so the user is abled to leave it as it is or change it if needed. Convenient.
Fill the user info into a hidden field:
- Code: Select all
<input type="hidden" name="username" id="username"
value="<?= $user->name; ?>" />
This will add a hidden field to your form which will transfer the username to the recipient without printing it on the screen. Usefull if you want to transfer lot of info in the form, which the user doesn't need to see, but the recipient does.
If you want to user other info than the user name you just replace the php snippet part with:
- Code: Select all
<?= $user->username; ?>
<?= $user->email; ?>
<?= $user->password_clear; ?>
<?= $user->id; ?>
...
For the username, the users e-mail address and so on...
A full list of the possible user info you can use with this function is available here:
http://api.joomla.org/Joomla-Framework/User/JUser.html
Just a small feature, but comes in handy from time to time. :-)
Haphe phun, Savant
