Hi folks
I have a snippet that checks whether the logged in user is an admin logged into the manager.
It has always worked fine on my sites but on one particular site it works on one page, and fails on another.
Here’s the code:
<?php
$continue = 0;
if ($disable==1) {
$continue = 1;
}
if ($check=='get' && $_GET['admin']==1) {
$continue = 1;
}
else
{
if (($check=='ip'))
{
// only check if admin's IP is in system variable
$ip = $modx->config['admin_ip'];
if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$remote_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$remote_ip = $_SERVER['REMOTE_ADDR'];
}
if ($ip==$remote_ip)
{
$continue = 1;
}
}
if ($check=='mgr')
{
if ($modx->user->isMember('Administrator')) {
log_info('admin', true);
$continue = 1;
} else {
log_info('not admin', true);
}
}
}
return $continue;
When I run this snippet on one page it outputs ‘admin’ just fine in the logfile, but on another page it outputs ‘not admin’.
Is $modx->user->isMember(‘Administrator’) breaking from one page to the next?
Any ideas?