postLogin

The postLogin hook is triggered after a user has logged in. This can be either in the back end or the front end. It passes the user object as argument and does not expect a return value.

Using the postLogin hook has been deprecated and will no longer work in Contao 5.0. You can use the security.interactive_login event instead for example.

Parameters

  1. \Contao\User $user

    The back end or front end user (object) which has been logged in.

Example

// src/EventListener/PostLoginListener.php
namespace App\EventListener;

use Contao\CoreBundle\ServiceAnnotation\Hook;
use Contao\User;

/**
 * @Hook("postLogin")
 */
class PostLoginListener
{
    public function __invoke(User $user): void
    {
        if ($user instanceof \Contao\FrontendUser) {
            // Do something with the front end user $user  
        }
    }
}

References