WDTUTORIALS

Drupal 8 - How To Disable Access To Single Nodes With Rabbit Hole Module

Tutorial on how to control access to the /node/[nid] page.

Use Case

You have a view that lists articles but you want to disable access to single articles in node/[nid].

Installation

drush -y en rabbit_hole

How To Use It

Go to admin/modules and enable the entity types you want to restrict access to:

Go to admin/structure/types/manage/article and you can find the Rabbit Hole settings at the bottom.

Select Access denied as the behavior:

Now you can see the articles listed in the front page:

But if you click them, you get access denied:

Options

Go to /admin/structure/types/manage/article

You can also choose Page not found behavior or make a Page redirect:

Install Token module to see the token widget in the image.

In this case you would be redirected to the login page whenever you try to access an article in node/[nid].

Overrides And Permissions

You can allow these settings to be overridden for single entities in /admin/structure/types/manage/article:

Edit any article and you have the option to change the behavior for that single entity:

You can also allow certain roles to bypass Rabbit Hole in /admin/people/permissions:

Links

Samuli Natri built his first website in the late 90’s. He is very passionate about web technologies. He attended Helsinki University Of Technology (Computer Science) and Helsinki University (Social Sciences). He is the founder of WDTutorials.com.

Featured Python Tutorial For Beginners - Essentials In 1 Hour

Copyright @ 2018 WDTutorials.com. All rights reserved. Privacy policy.Terms Of Service.