Protect Drupal Content with Node Access Password


Node Access Password is a module that allows you to password-protect your Drupal content.

This module will automatically generate a random password for each node you want to protect. That password must be entered before viewing the content.

We’re going use the example of a real estate website. We’re going to set up a Property Manager who can give access to individual properties by handing out passwords.

The Property Manager case will be able to view the passwords created and give those passwords out.

Step 1. Install the four required modules


Node Access Password is a single module, but it won’t operate without three dependencies. You will need to install and enable all of these modules:

Step 2. Enable all the modules

  • Return to the Module page and check the boxes next to the modules.
  • Scroll to the bottom of the page and save.
  • Double check that all are checked. You can’t activate a module until it’s dependencies are activated, so you can’t always activate everything at once.

Step 3. Add a new role

  • Go to People > Permissions > Roles. We’re going to create the role for the Property Manager.

  • Type in the name of the role.
  • Click Add role.
  • Click Save order.

Step 4. Edit role permissions

  • Click edit permissions after the role is added and saved.

A quick reminder about permissions: Permissions let you control what users can do and see on your site. You can define a specific set of permissions for each role. Two important roles to consider are Authenticated Users and Administrators. Any permissions granted to the Authenticated Users role will be given to any user who can log into your site. You can make any role the Administrator role for the site, meaning this will be granted all new permissions automatically. You can do this on the User Settings page. You should be careful to ensure that only trusted users are given this access and level of control over your site.

  • Grant permissions for Content Access.

  • Grant permissions for any content types you want the property manager to have access to. There may be more than one type.
  • Double check the entire permissions list for permissions you should grant. Other modules you have installed may need attention.
  • You won’t see the “Property” type until you’ve created it. We’ll create that in the next step.
  • You will need to return to the role permissions after the content types are set up.

Step 5. Create a Content type Called Property

  • Go to Structure > Content types.
  • Create a content type called Property.

Step 6. Add the Password Field to Property

  • Go to Structure > Content types > click manage fields next to Property.
  • Choose Node access password as the Type of data to store.
  • Make sure the widget is also Node access password.

Step 7. Define per content access control

  • After creating the field, you will now see an Access Control tab.
  • Give the Property Manager the access you want that role to have.

  • Go through each section of the content control and create the formula that is going to work for you. You may want to adjust the anonymous and authenticated user access. Trial and error after you’ve got it all working is the best method.
  • Be sure to check “Enable per content node access control settings.”
  • Optionally you can enable per content node access control settings. If enabled, a new tab for the content access settings appears when viewing content. You have to configure permission to access these settings at the permissions page.

Step 8. Create the content

  • Go to Add content > Property.
  • Check the box next to the password field you created. Your field label may be different than mine.
  • Save and publish your entry.

  • The password will be generated and visible on the View tab when you are logged in with the proper permissions.
  • You can give this password out to your users.

Step 9. The Access control Tab

  • After creating the node, you will see an additional tab called Access control.
  • Click the Access control tab to view the password or to create new access rules.

Step 10. Give Selected Users a Link to the Content

  • You can create a menu item or you can simply give them a link directly to the page.
  • In the example above I went directly to the page via the URL. If I try to view the content directly, I get the message “Access is denied”.
  • There is a password prompt which I will have to deal with before I can see the content.


0 0 votes
Article Rating
Notify of

Newest Most Voted
Inline Feedbacks
View all comments
11 years ago

Hey there!

Thanks for the great tutorial. I followed all your steps, but in my installation, there is no password prompt showing up. Can you help me please?

Thanks a lot.


11 years ago

I’m trying to figure out a way to restrict access to nodes / pages, except by one user (not role). Basically I want a user to be able to log in and access a page / folder or file that only they can see. Would this setup that you have posted here be able to accomplish that, or do you know of another way? Thank you.

11 years ago

good morning

I’m following the tutorial but I can not generate the password.

What can I do to try to work out?

thank you

11 years ago

The password is not generated..

What can I do now?

Would love your thoughts, please comment.x