I\'m working with symfony 1.4 & i use sfDoctrineGuardPlugin as a tool for authentifications.
I want to catch the Id of user in order te store it in my table.
if the user is authenticated, yes, you can use:
// inside an action
$id = $this->getUser()->getGuardUser()->getId();
// inside a template
$id = $sf_user->getGuardUser()->getId();
If the user is not authenticated, it'll throw an error.
Depends from where you are calling.
From the 'view':
echo $sf_user->getAttribute('user_id', null, 'sfGuardSecurityUser' );
echo $sf_user->getUsername();
From the 'controller' (as mentioned by Tom above):
echo $this->getUser()->getGuardUser()->getId();
echo $this->getUser()->getGuardUser()->getUsername();
(First line is 'id', second is 'username')