Last active
December 12, 2017 20:48
-
-
Save matdave/2ff99d5547483638fe37ba0e0a2b1f19 to your computer and use it in GitHub Desktop.
MODX Manager Redirect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add a system setting per user or group for 'manager_start_page'. | |
// The redirect contains action variable already, so you just need everything after '?a=' | |
// Set the plugin to run OnManagerLogin | |
$managerurl = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://'; | |
$managerurl .= $_SERVER['HTTP_HOST']; | |
$managerurl .= $modx->getOption('manager_url'); | |
//$modx->log(1,$managerurl. ' '.$_SERVER['HTTP_REFERER']); | |
if ($modx->event->name == 'OnManagerLogin' && $_SERVER['HTTP_REFERER'] == $managerurl){ | |
$managerRedirect = $modx->getOption('manager_start_page'); | |
if(!empty($user)){ | |
$settings = $user->getSettings(); | |
if(!empty($settings['manager_start_page'])){ | |
$managerRedirect = $settings['manager_start_page']; | |
} | |
} | |
if(!empty($managerRedirect)) | |
$modx->sendRedirect($managerurl.'?a='.$managerRedirect); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment