postLogout

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.

Parameters

  1. \Contao\User $user

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

Example

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

use Contao\CoreBundle\ServiceAnnotation\Hook;
use Contao\User;
use Terminal42\ServiceAnnotationBundle\ServiceAnnotationInterface;

class PostLogoutListener implements ServiceAnnotationInterface
{
    /**
     * @Hook("postLogout")
     */
    public function onPostLogout(User $user): void
    {
        if ($user instanceof \Contao\FrontendUser) {
            // Do something with the front end user $user  
        }
    }
}

References