Tags

3 different ways to get the current login user


1 $this->getUser()->getGuardUser()->getId();
2 sfContext::getInstance()->getUser()->getGuardUser()->getId();
3 $this->getContext()->getUser()->getAttribute('user_id','','sfGuardSecurityUser');

// To get current user id
$user = sfContext::getInstance()->getUser();
$user = $user->getAttribute('User', null, 'User');
// e.g
$user->getId(); 
Advertisements