Forums

Automatically logging logged in user

Tim Lund 28 Jun, 2008
As well as a timestamp and IP address, I'd like a form to log automatically the logged in user name. I guess there has to be some PHP expression which get this, and one way I can see of doing what I want is to use phpAdmin to add a column to the table created by chronForms, and extend the SQL string started with INSERT in autogenerated code appropriately. Do you agree this will work? What is the php expression I need? Is it the best way of doing it?

Apologies in advance if this is answered somewhere in the FAQs, or if it is more a native Joomla question.
GreyHead 29 Jun, 2008
Hi Tim,

Search the forums here for $my - this used to be a common question. If you don't find an answer that works for you please come back and ask again.

Bob
Tim Lund 29 Jun, 2008
I've inserted the line

'".$my->email."' ,

in the Autogenerated code, and although I don't get an error, I don't get my email address appearing in the new field I set up. OTOH, when I have

[email]'me@mydomain.com[/email]' ,

the new field IS populated. Do I need to initialise $my somehow - like you have a line of code to initialise $database? This is probably trivial - just me not knowing much about php
GreyHead 29 Jun, 2008
Hi Tim,

Try
<?php
global $my;
?>
that was good for Joomal 1.0.x

Bob
Tim Lund 29 Jun, 2008
Actually, this does it:

$my =& JFactory::getUser();
GreyHead 30 Jun, 2008
Hi Tim,

That's it, one of these days I'll get to learn all the new Joomla 1.5 codes too.

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