Page 1 of 1

How can I get the current user_id?

Posted: Tue Mar 11, 2008 1:45 pm
by TestFreak
Hi,

I am using component Community Builder, and I have a own-created php-file which is loaded only for the first time a user loggs in. There is a button, on which a php function updates a field in the jos_component table.

The problem is, I don't know how to get the user_id of the logged user. (I need it because I want to update his field in this table)

Can anyone explain to me, how i can get this? Perhaps include a certain php file?

Re: How can I get the current user_id?

Posted: Sat Mar 15, 2008 2:55 pm
by radiant_tech
If you are running J! 1.5.x, you can get the user_id with

Code: Select all

$user = &JFactory::getUser();
$user_id = $user->get('id');

Re: How can I get the current user_id?

Posted: Mon Mar 17, 2008 3:40 am
by Aditu
great! :)
this is the answer ive been looking for!
yet im getting this message when i load my php file

"Fatal error: Undefined class name 'jfactory' in /w/web_docs/Facultades/Artes/ingenieriasonido/sat/submit/turn_verify.php on line 420"

how do i fix it ?

if it helps i have Joomla 1.5 RC4 with Community Builder 1.1 installed.

Re: How can I get the current user_id?

Posted: Mon Mar 17, 2008 9:04 pm
by Aditu
i have found the supossed answer for me...here

http://forum.joomla.org/viewtopic.php?f ... la#p922767

it looks like a nono for me :(