Display CMP after manager login for specific user group

Is there a way to display a MIGX CMP in the manager directly after login for a certain user group? I know the CMPs have their own URL, so I’m hoping there’s some way to simply redirect to that after login?

Maybe you can create a Plugin that runs on the event OnManagerLogin.
Then check if the user is in the correct user group and execute $modx->sendRedirect($cmp_url);

1 Like

Seems to work great, here’s my code:

$cmp_url = "https://...";
$groups = $modx->user->getUserGroups();

if (in_array(2, $groups)) {
    $modx->sendRedirect($cmp_url);
}

You could also use $modx->getOption('site_url'); so you don’t have to hardcode the whole url.
And as an alternative, there is also the isMember-function to check for a user group.

1 Like

That seems a little more straight forward, here my updated plugin:

$cmp_url = $modx->getOption('site_url') . "manager/?a=index&namespace=migx&configs=berichte";
$user = $modx->getUser();

if ($user->isMember('Berichte')) {
    $modx->sendRedirect($cmp_url);
}

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.