How to include joomla user's information

isaac_ho 25 Oct, 2007
Dear All,

Is there any way to include joomla (who has login) users' information in the form and output email.

for example:

User admin login and access the form, input everything and submit.

I want the name of admin and his email are included in the output email.

Thanks!
Max_admin 26 Oct, 2007
Hi,

You can get the logged in user name through this code :


<?php
global $my;

echo $my->username;
?>


put it in the email template field or a hidden one in the html.

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Lawrax 16 Nov, 2007
I've tried the above, and I get nothing.

That is, the username is not printed out or put into a field.

On the other hand, it doesn't cause my page to break.
GreyHead 16 Nov, 2007
Hi lawrax,

What exactly do you want to do? This code should show the user name in Joomla 1.0.x (might be different in 1.5 I'd need to check). Have you put this into an email template? or your html code?

Bob
Lawrax 17 Nov, 2007
Yes, both.

Oh, and I am using Joomla 1.5.
Max_admin 17 Nov, 2007
Hi Lawrax,

for joomla 1.5 the code is :

<?php
$user = &JFactory::getUser();
echo $user->username;
?>
Cheers

Max<br><br>Post edited by: GreyHead, at: 2007/11/18 07:56
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
compugeek 28 Nov, 2007
Here is a form I made so my users can submit news. It will show the user name in the form and will e-mail the user name to me so I know who sent it.
Hope it helps.
<?php global $my; ?>
<div align="center"><h2 style="color: #cc3300;">Submit News </h2></div>
<hr>
<input type="hidden" name="username" value="<?php echo $my->username; ?>" />
Thank you for taking the time to submit your news <?php echo $my->username; ?>
<p>Would you like us to contact you for more info? <input type="radio" name="contact" value="
YES_contact" id="ff_elem183"> <label id="ff_lbl183" for="ff_elem183">Yes </label>
<input type="radio" name="contact" value="no_contact" id="ff_elem184"> <label id="ff_lbl184" for="
ff_elem184">No </label></p>
<hr>
<div align="Center"><strong>News Details</strong></div>
<blockquote>
<p>Title:</p>
<p><textarea cols="30" name="Title" id="ff_elem205" style="height:63px; width:500px;" rows="4"></textarea></p>
<hr>
<p>Description:</p>
<p><textarea cols="60" name="Description" id="ff_elem206" style="height:63px; width:500px;" rows="5"></textarea></p>
<p><input type="submit" value="Submit News" name="Submit" style="font-style:italic; font-weight: bold;">       
<input type="reset" value="Reset (cancel form)" name="reset" style="font-size:8pt; font-style:oblique;"></p>
<hr>
Edited to add code tags, image & correct a few typos

How to include joomla user's information image 1<br><br>Post edited by: GreyHead, at: 2007/11/27 19:52
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger