Hide user login

Last updated on
23 May 2021

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

In the default setup the Drupal login block is always displayed unless a user is logged in. This may not always be desirable. For example, if you are using Drupal to create a site that has a very small number of people actually logging into the system to create or edit content, then you probably don't want a large portion of your screen real-estate taken up with a login block that only serves a small minority of users. This also confuses the majority of your users that will not have the option to log in.

To disable the login block

  1. Go to the blocks administration page:
    • Drupal 6: Administration » Site building » Blocks
    • Drupal 7: Administration » Structure » Blocks
    • Drupal 8: Manage » Structure » Block layout
  2. In the Region column next to User login select None
  3. At the bottom of the page, click Save Blocks

Your regular content editors and administrators can still log in to the site by directly accessing the login page:

NOTE FOR DRUPAL 8: If you do not have any content on the front page and remove the default "Front Page" under configuration >> settings, the default content for the front page is the user page or the login form for users who are not logged in. This can not be removed through the block layout system. 

Selectively hide the login block

Since the login block is a normal block, you can configure it on the blocks administration page. Use the configure link next to each block and you will be given options to set the visibility of the block by page:

by content type:

or by role:

Hide the login page

You can hide the login page from anonymous users and bots by requiring a secret querystring by enabling the disable login page module in D8 / D9. This can be useful on sites that do not need any public login and only needs webmasters or select few internal users.

Move the login page

Obscurity is not security, and it is essentially impossible to hide that a site runs Drupal. Still, it is possible to move the login page from /user to another path with the Rename Admin Paths module.

Help improve this page

Page status: No known problems

You can: