Robin van der Vleuten

Masking content in Drupal

Today I released a small module for hiding parts of your content from everyone except specific roles, users, or organic groups. It is based on WordPress's shortcode API and works together with a Drupal text format.

A simple example looks like this:

bash
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ac ligula
non augue scelerisque dapibus vel et ante. Pellentesque volutpat nibh ut
ipsum bibendum euismod. Ut nibh nisi, aliquam sed ornare eu, hendrerit
quis nunc. Nam vel nunc sed erat dapibus accumsan id eget nunc.
[content_mask uid="1"]
Mauris ornare augue ac augue tempor auctor. Praesent justo ligula,
convallis quis semper a, eleifend ut mi. Etiam eleifend aliquet
quam, accumsan eleifend erat vestibulum at. Pellentesque habitant
morbi tristique senectus et netus et malesuada fames ac turpis egestas.
[/content_mask]
[content_mask role="editor|administrator"]
Praesent rutrum, ligula vitae porta faucibus, nunc ante consequat est,
in imperdiet eros odio vitae nunc.
[/content_mask]

You can mask content based on a user's UID or role. The attribute on the shortcode describes who is allowed to view the content.

The module's project page is on Drupal.org, with the code and issue queue there too.