0
votes

I've found this plugin code:

<!--?php
if ($modx--->event->name == 'OnManagerLogin') {
    $path = $modx->getOption('base_url',null,MODX_BASE_URL);
    $modx->sendRedirect($path.'manager/?a=69');
}

but I cannot manage to make it work with MODX Revolution 2.5.0-pl. It seems that OnManagerLogin does not work at all. Am I the only one? Is it related to this?

https://github.com/modxcms/revolution/issues/11848

I've also tried this:

$e = $modx->event;
switch( $e->name ) {
case 'OnManagerLogin':
$modx->sendRedirect('http://modx.com',array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
}

but it did not work. Can anyone help?

1

1 Answers

0
votes

Solution is here With this code :

$url = 'http://www.example.com/manager/';

$groups = array(
    'admin_ceremonie' => 'http://www.example.com/manager/?a=resource/update&id=1138',
);

$userId = $user->get('id');
$searchCriteria = array(
    'user' => $userId,
    'key' => 'LoginResourceUrl',
);
$userSetting = $modx->getObject('modUserSetting', $searchCriteria);

if ($userSetting) {
    $url = $userSetting->get('value');
} 
else {
    foreach($groups as $groupName => $pageUrl) {
        if ($user->isMember($groupName)) {
             $url = $pageUrl;
            break;
        }
    }
}

$modx->sendRedirect($url);