title: catching the login event of ZfcUser with Zend framework 2
body: <p>i am using <strong>zfcUser</strong> with <strong>Zend Framework 2</strong>.</p>
  
  <p>i want to capture the login event so that i can do something with it and also redirect the user to a different page. </p>
  
  <p>i know how to catch the register event. ie i place a onBootstrap in my module.php file and then do the following </p>
  
  <pre><code>$em-&gt;attach('ZfcUser\Form\RegisterFilter','init',function($e)
  </code></pre>
  
  <p>the entire function is like this;                </p>
  
  <pre><code>public function onBootstrap(MVCEvent $e)
  {
          $eventManager = $e-&gt;getApplication()-&gt;getEventManager();
          $em           = $eventManager-&gt;getSharedManager();
          $em-&gt;attach(
                  'ZfcUser\Form\RegisterFilter',
                  'init',
                  function($e)
                  { }
  }
  </code></pre>
  
  <p>However, when i tried to catch the login event i did not have any results. i.e </p>
  
  <pre><code>$zfcServiceEvents-&gt;attach('login.post', function($e) {
                  echo "loggedn"; die();
              });
  </code></pre>
  
  <p>would really appreciate some help.</p>
  
  <p>thank you. </p>
  
  <p>edit: </p>
  
  <p>this is how i called the registered event ( i know how to called the event for a user who has just registered. but i want to call the event when a user has just succesfully logged in </p>
  
  <p>public function onBootstrap(MVCEvent $e)
      {</p>
  
  <pre><code>$zfcServiceEvents = $e-&gt;getApplication()-&gt;getServiceManager()-&gt;get('zfcuser_user_service')-&gt;getEventManager();
  
  $zfcServiceEvents-&gt;attach('register', function($e) {
  $form = $e-&gt;getParam('form');
  $user = $e-&gt;getParam('user');
  </code></pre>
  
  <p><strong>RESPONSE TO cptnk CODE</strong></p>
  
  <p>in response to the answer given by cptnk i tried the following code but it did not work;</p>
  
  <pre><code>public function onBootstrap(MVCEvent $e)
  {
  $sharedManager = $e-&gt;getApplication()-&gt;getEventManager()-&gt;getSharedManager();
  
              $serviceManager = $e-&gt;getApplication()-&gt;getServiceManager();
  
                  $loginFunction = function ($e) use ($serviceManager) { 
                      echo "eventCaptured" ; die();
                  };
  
              $sharedManager-&gt;attach('ZfcUser\Service\User', 'login.post', $loginFunction);
  
  }
  </code></pre>
  
  <p>i am still not able to capture the login event.Any ideas?</p>
  
  <p>cptnik had a good suggestion; he asked whether i had overridden the ZFcUser-service. in responce i clarfiy that i had overridden the zfcuser. below is the code i used; </p>
  
  <pre><code>'zfcuser' =&gt; array(
          // telling ZfcUser to use our own class
          'user_entity_class'       =&gt; 'BaseModel\Entity\User',
          // telling ZfcUserDoctrineORM to skip the entities it defines
          'enable_default_entities' =&gt; false,
      ),
  </code></pre>