The postLogout
hook is triggered after a user has logged out from the back end
or front end. It passes the user object as argument and does not expect a return value.
Using the postLogout
hook has been deprecated and will no longer work in Contao 5.0.
\Contao\User $user
The back end or front end user (object) which has been logged out.
// src/EventListener/PostLogoutListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\User;
#[AsHook('postLogout')]
class PostLogoutListener
{
public function __invoke(User $user): void
{
if ($user instanceof \Contao\FrontendUser) {
// Do something with the front end user $user
}
}
}