By user3108268


2019-07-08 11:56:51 8 Comments

The solution for Drupal 7 is using the following code, as per answer of How can I disable the message “Operating in maintenance mode. Go online.” in maintenance mode?

function mytheme_preprocess_page(&$vars) {
  if (variable_get('maintenance_mode', 0)) {
    $message_count = count($_SESSION['messages']['status']);
    if($message_count > 1) {
      array_shift($_SESSION['messages']['status']);
    }
    else {
      unset($_SESSION['messages']['status']);
    }
  }
}

What is the solution for Drupal 8?

I cannot figure out how to do it with https://www.drupal.org/project/disable_messages.

Hide/disable the message for everyone including the user #1.

1 comments

@user89751 2019-07-08 14:04:04

Drupal 8 version:

function mytheme_preprocess_status_messages(&$variables) {
  if (\Drupal::state()->get('system.maintenance_mode')) {
    $message_count = count($variables['message_list']['status']);
    if ($message_count > 1) {
      array_shift($variables['message_list']['status']);
    }
    else {
      unset($variables['message_list']['status']);
    }
  }
}

Related Questions

Sponsored Content

7 Answered Questions

[SOLVED] How do I turn off maintenance mode?

  • 2014-01-22 20:00:14
  • John
  • 33495 View
  • 7 Score
  • 7 Answer
  • Tags:   maintenance-mode

1 Answered Questions

[SOLVED] Maintenance mode and user session

  • 2018-06-29 09:02:02
  • Michael
  • 137 View
  • 1 Score
  • 1 Answer
  • Tags:   maintenance-mode

1 Answered Questions

[SOLVED] hook for maintenance mode

  • 2018-05-17 10:13:28
  • shasi kanth
  • 54 View
  • 2 Score
  • 1 Answer
  • Tags:   7 maintenance-mode

2 Answered Questions

[SOLVED] Site stuck in maintenance mode

  • 2011-03-03 12:12:22
  • kiamlaluno
  • 9990 View
  • 15 Score
  • 2 Answer
  • Tags:   maintenance-mode

1 Answered Questions

[SOLVED] Maintenance mode says it's on, but site is still available

  • 2016-06-08 20:55:16
  • eljefejb
  • 74 View
  • 0 Score
  • 1 Answer
  • Tags:   maintenance-mode

4 Answered Questions

[SOLVED] What does maintenance mode do?

  • 2015-03-12 03:00:43
  • Allen
  • 1862 View
  • 0 Score
  • 4 Answer
  • Tags:   maintenance-mode

1 Answered Questions

[SOLVED] Adding Information to Maintenance mode message

  • 2013-12-11 20:49:44
  • CW Smith
  • 291 View
  • 0 Score
  • 1 Answer
  • Tags:   maintenance-mode

1 Answered Questions

[SOLVED] Maintenance mode doesn't work on front page without www prefix

Sponsored Content