This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation

This will make it so that If you are in the Administrators group, you can access and edit the site even when it is in maintenance mode!

At this time we can't override the php file by copying it out of the /concrete directory, so we are going to have to do it in the core. (when we are done don't forget to make a backup!)

First we are going to open:

/concrete/startup/maintenance_mode_check.php

it should look something like this:

<?
defined('C5_EXECUTE') or die("Access Denied.");
if ((!$c->isAdminArea()) && ($c->getCollectionPath() != '/login')) {

    $smm = Config::get('SITE_MAINTENANCE_MODE');
    if ($smm == 1) {
        $v = View::getInstance();
        $v->render('/maintenance_mode/');
        exit;
    }

}

First we are going to check if they are in the Administrators group, so we have to initialize the user object:

$u = new User();

Now we need to initialize the group:

$g = Group::getByName('Administrators');

Now that we have both objects, we have to check if the user is in the group:

$u->inGroup($g);

If it returns true, then the user is in that group, if not then the user is not in that group.

Now just in-case, we want to check if the user is the super user,

$u->isSuperUser();

so what we have right now is:

$u = new User();
$g = Group::getByName('Administrators');
$u->inGroup($g);
$u->isSuperUser();

Thats great but it doesn't do anything yet,

What we are going to do is make an "if" statement:

if ($u->inGroup($g)||$u->isSuperUser()) {
    //its an admin!
}

The 2 || means "or". So if the the user is in the "Administrators" group or is the Super User do something.

But we want to do nothing if they are an admin, so we are going to stick in 2 ! which means "not".:

if (!$u->inGroup($g)||!$u->isSuperUser()) {
    //its not an admin!
}

Now we are going to put all the code together:

defined('C5_EXECUTE') or die("Access Denied.");

$u = new user();
$g = Group::getByName('Administrators');

if (!$u->inGroup($g)||!$u->isSuperUser()) {
    //its not an admin!
    if ((!$c->isAdminArea()) && ($c->getCollectionPath() != '/login')) {
        //its not the dashboard or login page
        $smm = Config::get('SITE_MAINTENANCE_MODE');
        //is maintenance mode on?
        if ($smm == 1) {
            //yes it is! lets render the maintenance mode page
            $v = View::getInstance();
            $v->render('/maintenance_mode/');
            exit;
        }
    }
}
 

Loading Conversation