Accessing the current user object

Is there a way to get a JUser object by real name?

It is possible, to get it by SELECTing its id from the database, but that just not seems like the right way to me.

--UsagiYojimbo 10:16, 18 November 2009 (UTC)

Import new user id to a table


I have created a plugin that inserts a record in a new table when a new user registers. Im using the function onAfterStoreUser and $user = & JFactory::getUser(); $id_user = $user->get('id'); to get the new id. The problem is that the $id_user get the value 0 because the user is created but not logged in.

How else can i get the id of the new user?