Jump to main content Jump to doc navigation

Event: OnBeforeManagerLogout

Fires before a user is logged out of the manager. The logout hasn't occured yet.

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

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 occuring in. Passed by reference

Examples of

Such a plugin will write to the "Error log" the id of the logged out user and where he left from:

<?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));
        break;
}

Such a plugin will display a message to the user that he cannot leave the context. mgr:

<?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
  • Fabian Christen
  • Dannevang Digital
  • Sepia River Studios
  • CrewMark
  • Chris Fickling
  • deJaya
  • eydolan
  • Lefthandmedia
  • Murray Wood
  • Following Sea
  • Anton Tarasov
  • Stéphane Jäggi
  • Raffy
  • Snow Creative
  • A. Moreno
  • Nick Clark
  • JT Skaggs
  • Helen
  • YJ
  • krisznet
  • Richard
  • Yanni

Budget

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

Learn more