How can I get the current user_id? Topic is solved

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
TestFreak

How can I get the current user_id?

Post by TestFreak » Tue Mar 11, 2008 1:45 pm

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?

radiant_tech
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Sat Dec 15, 2007 3:02 pm
Location: Washington DC Metro

Re: How can I get the current user_id?

Post by radiant_tech » Sat Mar 15, 2008 2:55 pm

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');
Denise

User avatar
Aditu
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sun Sep 30, 2007 7:17 pm

Re: How can I get the current user_id?

Post by Aditu » Mon Mar 17, 2008 3:40 am

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.

User avatar
Aditu
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sun Sep 30, 2007 7:17 pm

Re: How can I get the current user_id?

Post by Aditu » Mon Mar 17, 2008 9:04 pm

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 :(


Post Reply