Jump to main content Jump to doc navigation

Event: OnBeforeManagerLogout

Fires before a user logs out of the Manager.

  • Service: 2 - Manager Access Events
  • Group: Security

Event Parameters

Name Description
& user A reference to the modUser object of the user. Passed by reference
userid The user ID of the user. (deprecated)
username The username of the user. (deprecated)
& loginContext The context key this logout is occurring in. Passed by reference
& addContexts Additional contexts in which the logout is also occurring in. Passed by reference

Examples

<?php
$eventName = $modx->event->name;
switch($eventName) {
    case 'OnBeforeManagerLogout':
        $modx->log(modX::LOG_LEVEL_ERROR, 'User with id'.$user->get('id').' logged out in context '.$loginContext.' and also in these'.print_r($addContexts, true));
        break;
}

This Plugin blocks the logout when the user tries to leave the mgr Context:

<?php
$eventName = $modx->event->name;
switch($eventName) {
    case 'OnBeforeManagerLogout':
        //if he tries to run away, we leave him
        if ($loginContext === 'mgr'){
            $response = array(
                'success' => false,
                'message' => "You can't go out! You are one of us .. one of us .. one of us",
                'data' => array(),
            );
            echo $modx->toJSON($response);
            exit;
        }
        break;
}

See Also

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.

Backers

  • modmore
  • STERC
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • CrewMark
  • Fabian Christen
  • Sepia River Studios
  • Dannevang Digital
  • Alex
  • A. Moreno
  • Chris Fickling
  • Stéphane Jäggi
  • Murray Wood
  • Anton Tarasov
  • JT Skaggs
  • deJaya
  • Lefthandmedia
  • eydolan
  • Following Sea
  • Guido Gallenkamp
  • YJ
  • Raffy
  • Snow Creative
  • Nick Clark
  • Guest
  • Helen
  • krisznet
  • Yanni
  • Richard

Budget

$194 per month—let's make that $500!

Learn more