if ($modx->event->name == 'OnHandleRequest') { if (strpos($_SERVER['REQUEST_URI'], 'context2')) { $modx->user = null; $modx->switchContext('context2'); } }