I've created my theme as subtheme of ZEN, and I have created my maintenance page template, which works when I enable the maintenance page.

If I try to visit example.com/user, the login page is shown with the standard template, and not with the maintenance-page template.

How do I make Drupal 7 use the maintenance page template also for the login page?

  • There's a very good reason for this, which is if you put the site into maintenance mode via the UI, then accidentally click logout, you need to be able to login again. If you are using drush this may not be the case of course. Mar 19, 2013 at 17:09

2 Answers 2


If you want the login page to look different when you are in maintenance mode you theme it by checking the maintenance mode variable like this:

if (variable_get('maintenance_mode', 0)) {
  // Do something because it is maintenance mode.

For example, in your page template you could do this:

 * Preprocess variables for the page template.
function THEME_NAME_preprocess_page(&$variables) {
  if (variable_get('maintenance_mode', 0)) {
    // Add a template suggestion for pages that are not the maintenance
    // page, while the site is in maintenance mode.
    $variables['theme_hook_suggestion'][] = 'page__inmaintenancemode';

Then you could make a page--inmaintenancemode.tpl.php file, that could be used to theme any pages that are visible while in maintenance mode. Be aware though that this will then affect all pages you see when you are logged in during maintenance mode, so you might want to change the line that check for maintenance mode to:

if (variable_get('maintenance_mode', 0) && user_is_logged_in()) {

You can do the same check in hook_form_alter() or in other template preprocessors, or anywhere else you are modifying content.


I take it this is a temporary patch while you're developing the site, right? You could trick Drupal into using the maintenance page in place of the user-login.tpl.php by setting up a symbolic alias from the command line, ex:

ln -s maintenance-page.tpl.php user-login.tpl.php

Of course if you currently have a user-login.tpl.php file in your theme you're going to want to move it to a backup version first, ex:

mv user-login.tpl.php user-login.bak.tpl.php

Then when you're ready to make the switch back, just remove the symbolic link and mv the file back:

rm user-login.tpl.php
mv user-login-bak.tpl.php user-login.tpl.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.