event->name) { case 'OnManagerPageBeforeRender': // Here we need to check if we are displaying the "welcome" controller if (!$modx->event->params['controller'] instanceof WelcomeManagerController) { return; } // Assume we always want to display the welcome message, no matter how global welcome_screen setting is configured $show = true; // Check the current user "preference" $setting = $modx->getObject('modUserSetting', [ 'key' => 'welcome_screen', 'user' => $modx->user->get('id'), ]); if ($setting) { // user option found, let's use it instead $show = (bool) $setting->get('value'); } // Set the option temporarily so the welcome controller could do whatever it takes $modx->setOption('welcome_screen', $show); break; case 'OnUserFormSave': // A user is saved, let's make sure to process only when a user is created if ($modx->event->params['mode'] !== modSystemEvent::MODE_NEW) { return; } // User has just been created, assume we want to create a user setting /** @var modUser $user */ $user = $modx->event->params['object']; // First make sure the setting does not already exist /** @var modUserSetting||null $setting */ $setting = $modx->getObject('modUserSetting', [ 'key' => 'welcome_screen', 'user' => $user->get('id'), ]); if (!$setting) { // No user setting found, let's create it! /** @var modUserSetting $setting */ $setting = $modx->newObject('modUserSetting'); $setting->fromArray([ 'key' => 'welcome_screen', 'user' => $user->get('id'), 'xtype' => 'combo-boolean', 'area' => 'manager', 'namespace' => 'core', ], '', true); } $setting->set('value', true); $setting->save(); break; } return;