I created a new content type with the CCK module and manage the access permissions through roles and users. So far it looks OK. An anonymous user can only view the content, an administrator and member can view and edit the content.
In our case an administrator is allowed to update and delete the node, but a member should only be granted to view and update a node.

Is there an easy way to remove or disable the delete button?

Many Thanks,
Chris

Comments

Anonymous’s picture

The way I have dealt with this kind of scenario in the past was to use hook_alter in a small custom module.

Something in the lines of:

function whatever_form_alter($form_id, &$form) {
  if ($form_id == 'your_form') {
    unset($form['button_name']);
  }
}

hih
FnL

chdom’s picture

Hi FnL,

Thanks for your post but something was missing.
Don't forget that Drupal handles $form_id its own way (I don't really understand how in fact).
I attempted to write the value of the id property of the form instead of "your_form" but it didn't work. One must print what $form_id is set to by adding a line (now commented) to make sure.

function whatever_form_alter($form_id, &$form) {
#print "+ ".$form_id." +";
if ($form_id == 'your_form') {
unset($form['button_name']);
}
}

For example if you want to remove the two links in the user_login_form below the form : the id of the form is "user-login-form" but $form_id is set to "user_login_block" (the name of the function perhaps ?).
So the code is :
function whatever_form_alter($form_id, &$form) {
#print "+ ".$form_id." +";
if ($form_id == 'user_login_block') {
unset($form['links']);
}
}

another way is to write (don't ask me why):

function whatever_form_alter($form_id, &$form) {
drupal_render($form['links'];
}

PS : One must replace "whatever" by the name of his module and "button_name" by the name of the field of course.

Hope this helps

Cheers

Laurentvw’s picture

node.module patch for this issue is available here: http://drupal.org/node/153998

---
Breaking News: Yunar | Long live democracy! | Buddy 4 life: Prameya