By 2c on
Is it possible to give a user the access rights to edit their own post but not to delete it.
As an alternative to this, it would be nice if a user could delete their post ONLY if NO comment has been made on it.
Is it possible to give a user the access rights to edit their own post but not to delete it.
As an alternative to this, it would be nice if a user could delete their post ONLY if NO comment has been made on it.
Comments
Since the right to delete is
Since the right to delete is included in 'edit' privilege, you need to create a custom module to do that. Save the module below to your modules dir, accompanied by an appropriate .info file. Enabling this module will allow only the user #1 to delete nodes with comments. If you don't want users to delete their own nodes regardless of the number of comments, remove '&& $node->comment_count > 0' in line 5.
Thank you
Awesome, I'll try this out this evening.
What if they go to /node/123/delete?
Looks good, dokumori, but what if a Drupal-savvy user goes to /node/123/delete? Don't you need some code to block that?
I'm not sure what the best way to do it is. Maybe using drupal_goto to redirect them to a page that explains why they can't delete their node? You might include a link on that page to email an administrator if it's really important that the node be deleted.
I think the
I think the http://drupal.org/project/content_access module gives you separate "edit" and "delete" permissions per content type.
...
I've tried it out and it does indeed work.
To approach the problem of users typing in the url directly:
Replace the 'ACCESS DENIED' in the code above with the URL of the page your users should get when they don't have permission to access a page.
yeah, i should have
yeah, i should have mentioned i wrote it in 5 min without much consideration :p
glad you spotted and fixed the problem.
Does this code go into the
Does this code go into the module w/the first set? never tried to make a module before.
This is a great little solution though if I can get it working.
Edit to add: I don't see why the direct url prevention part is needed... if I keyin the url as "athenticated user" I get "access denied" error anyway. What does the above add?
Well, this seemed to be
Well, this seemed to be working for a while, but now it isn't. Not sure what happened.
Made the module and .info file. Enabled.
But user who started the thread/topic can still delete it along w/his edit permission.
Ideas on why it isn't working?
Upgrade to Drupal 6
I upgraded my Drupal version 5 to version 6 and that gives me access to new 'Access controls'. This is located under Administer > User management > Permissions > node module.
In Drupal 6 'Access control' is call 'Permissions'.
New 'Permissions' such as:
Module Nodeaccess for Drupal 4, 5 & 6
If you do not want to upgrade to Drupal 6 debtman7 did a module call Nodeaccess. It works with Drupal 4, 5 & 6:
http://drupal.org/project/nodeaccess