-
☆ A M B ☆
- 24,524 Posts
You could use the OnPageUnauthorized event to specify which page to redirect to in a plugin. The plugin code would just need to set (re-set) the $modx->config[’unauthorized_page’] value to the page you want, depending on the page being denied. For example, you could check the $modx->documentObject[’template’] which will hold the template id of the page being processed (the one being denied) and set the unauthorized_page value accordingly.
I’ve tried it with multiple system events as triggers, and none seems to work... Am I missing something?
-
☆ A M B ☆
- 24,524 Posts
No, I am. The documentObject is not yet available. This will take a query to determine the document’s template. I’m working with it; should have a resolution shortly.
-
☆ A M B ☆
- 24,524 Posts
This does the job, using the OnPageUnauthorized event:
$rs = $modx->db->select('template', $modx->getFullTableName('site_content'), 'id = ' . $modx->documentIdentifier);
$tpl = $modx->db->getValue($rs);
if($tpl == 3) {
$modx->config['unauthorized_page'] = 5;
}
adjust the if (or make a switch out of it) as desired.
Thanks so much! I’m all kinds of new to plugins, this was super helpful.
-
☆ A M B ☆
- 24,524 Posts
I need to add this to my chapter on plugins.
http://www.sottwell.com/how-plugins-work.html
I’ve been playing with this and it doesn’t seem to be working for me... What is the best way to debug plugins?