Help support the XML sitemap rewrite! Individual donations are welcomed to help offset my free time on the project. If your company would like to sponsor the rewrite or a specific feature, please contact me. Also be sure to read this blog post!

Restricted content - Yet-another-but-different Drupal node access module

I previously posted about my search for my ideal content access module. Since then I've done a lot of searching and digging through the source code of all the most popular content access modules. I've come to realize there was really no module currently out there that had the features I was looking for. A quick review of the feature wish list:

  • Per-content access restricted by user roles
  • If the content is restricted to user, don't just hide the node, but rather show a message in place of the content like "Sorry, this post has been restricted to users with the following roles: registered user, friend."
  • If the current user is anonymous and the content is restricted, also show a message like "Please create an account to view this content." with a link to the user register page, of course.

restricted_content1 The built-in Drupal node access system is not really ideal for this direction since there's absolutely no middle ground between, "This user can view the node" and "OMG! Hide this node completely!" So today I started Restricted content, a yet-another-but-totally-different node access module. After only a couple hours of coding, it seems to be working fairly well, minus any kind of testing framework (I swear I'll get right on it webchick!). The content restriction messages shown to the user are customizable and can be integrated with token for some cool token replacement. For anyone daring enough to try it or even just take a look at the code, your comments and feedback are wanted and welcome here or in the issue queue. Hopefully some of you can find this useful like I have!

Comments

Anonymous's picture

Apart from the custom message feature, is Restricted content a lot different from the newly released content access module? That one seems to do pretty much the same things too.

Dave Reid's picture

They accomplish pretty much the same thing, but there's a lot more behind being able to display the restricted message. The Content access module uses the built-in Drupal node access system, which simply hides the node completely if there is no access. I had to write my own node-type access code that would still allow the node to be visible. So they may seem very similar, but underneath they could not be more different.

Anonymous's picture

What if there is an attached file, does that show?

Thanks

Dave Reid's picture

It won't show. I've tested the module with uploaded files, user pictures, taxonomy, etc.

Anonymous's picture

Hi Dave, i like your module. Another nice feature would be an option to show the teaser but not the full body of a node if access is not granted. What do u think?

Dave Reid's picture

Sounds valid. Please file a feature request at http://drupal.org/project/issues/restricted_content

Anonymous's picture

Good post. Keep up the good work.

Anonymous's picture

What about a 5.x version?

:)

Dave Reid's picture

Unfortunately I do not use Drupal 5 for any websites or projects, so I have no motivation to continue or backport my modules to Drupal 5. If someone is willing to sponsor my time (since all my module development is on my free time), that would be motivation. :)

Anonymous's picture

Great module, could not be easier to install & setup!

Good job, thanks!

Anonymous's picture

hi dave -

I ask this question a bit sheepishly ('cause i suspect the answer may be really obvious): how do I set restrictions using this module???

meaning: i've installed the Restricted Content, activated it, and set access restriction for anonymous users (under Permissions)... the module is pretty self explanatory in terms of setting up the messages... but how/where do i assign restricted status to a node (ie, tell node/x or content_type/x to be 'restricted content')??

am i just missing something?

thx!

Anonymous's picture

Is there a way to restrict access based on the user's sign up date?

Anonymous's picture

In your review of the access control modules, did you find anything that was more granular than a node?

I'm specifically hunting for a clean way to hide words, paragraphs, images, etc. for certain people, roles, and whatnot. Is there a "for your eyes only" function in any existing module?

For my use case, this would work by surrounding some portion(s) of my content with XML tags indicating who can or can't view it, using attributes for user names, OG names, or roles. An added bonus would be the ability to indicate alternate content for the "else" condition. This would be processed server-side.

Have you seen anything even close to this? Are there modules that you would suggest contributing to?

Dave Reid's picture

Ooh! I just discovered this one yesterday: Restricted Text (http://drupal.org/project/restricted_text) sounds perfect for what you're looking for.

Anonymous's picture

Wow, that's a great start! I hadn't thought about using input filters for that functionality. I'll need to look into performance issues that it may introduce.

I'll certainly try it out right away

Thanks for the pointer!

Anonymous's picture

Thank You very much :)

Your module is very useful for my requirement.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
Syndicate content