How to lock down a node to a role using drupal content access module
Took me a while to figure out how to use the drupal content access module correctly, maybe because the readme.txt file was pretty basic. Anyway, basically locking down a node to a role is a two step process. The first is done just once (well actually once for each new role added).
1) Define the default permissions you want on the content type.
So for my case I wanted all roles to be locked down to only edit own content (content created by the currently logged in user.)
Go to: Administer->Content Management->Content Types->Edit->Access Control
Tick: View/Edit/Delete own content.
Tick: Per content node access control settings.
2) When the user creates new content (a new node) they need to define which roles (other than themself) they want to give access.
That's it. Not sure why it was so hard to figure this out, but there you go.
If you want a page that displays nodes for a specific content type that are assigned a role that the logged in user is allowed to see then this is how I did it. Create a new page node and change the input type to PHP, then add this code and modify $show_content_type as appropriate.
uid . "))";
$result = db_query_range($query, 0, 1000);
echo "
";
while ($node = db_fetch_object($result)) {
echo "nid . "\">Edit "
. $node->title . "
";
}
}
?>
References:
http://drupal.org/project/content_access
Comments