How to restrict access to certain content on Drupal 8 site. To do this in Drupal 8, we are going to use the Content Access module.

To follow along with this tutorial, download and install Content Access. I found no errors while using this module, but please note that currently it is a dev release. You will need to enable both options provided.

  • ACL
  • Content Access

As soon as you have enabled the Content Access module, you will be greeted with a message asking you to rebuild the permissions. This is because the module has made changes to the way permissions will work.
Restricting Access to Content in Drupal 8
Now let’s create a new content type that will be restricted to authenticated users only.

  • Go to Structure > Content type > Add content type.
  • Create the content type that will have restricted access.

Restricting Access to Content in Drupal 8

  • On the main Content types screen click the Manage fields dropdown.
  • You will now see that you have an “Access control” option.

Restricting Access to Content in Drupal 8

  • Click the “Access control” link and you’ll see all the ways in which you control access to this content type.
  • In this example, I want only registered members to see the content, so I’ll uncheck all the “Anonymous user” boxes.

Restricting Access to Content in Drupal 8
Drupal and Content Access are smart enough to automatically hide any content (or menu links to that content) from users who don’t have permission to see it.

Here’s an example of my Drupal menu for logged-in users. You can see the “OSTraining content” link.
Restricting Access to Content in Drupal 8
And here’s that same menu for Anonymous users:
Restricting Access to Content in Drupal 8
If you need a more refined “content access” the module also allows you restrict access Per content nodeif you enable this you will need to set more detailed permissions via

  • People
  • Permissions

Using this module you can quickly set access control roles and restrictions.

Original: https://www.ostraining.com/blog/drupal/drupal-8-restricting-content/

0 Likes
992 Views

You may also like

Leave A Comment

Please enter your name. Please enter an valid email address. Please enter message.