0

I have a user with a role with restricted permissions. The content type is restricted to "Edit" only. However, the Operations Select box still displays Delete.

Well, as I can check several checkboxes of different kind of content, that is correct. But the problem is that the user can continue to the next screen, where she is asked if she wants to delete the item. IMHO, this message should never display, because the user has no deletion permissions, so it is quite confusing.

Can I override this screen in a simple way, so it will not listed those nodes which have no deletion permission?

  • Are you referring to the admin/content page or the node edit page? – longboardnode Nov 3 '15 at 18:47
1

There is always more than one way to skin a drupal, but they are rarely of equal merit.

It sounds like you have a page that is using Views Bulk Operations? If that is the case, find the view that generates the page and remove Delete from the operations selected.

If that is not the case, but you would like it to be, then see if the page in question is covered by Admin Views. Enable the module, find the related view, and modify it to suit you.

If that also is not the case, then fortunately for you this interaction is a form of some type. You can use a hook_form_ID_alter() function to change the $form['field']['#options'] array and remove Delete from it. If php is not your language, I am sure there is a javascript method of doing the same thing ... but I don't like that, feels like too weak of a solution. You can also have this same alter function check the global $user; $user->roles array so you retain the delete function for yourself.

If you want to let the user in question retain the Delete option, and just fail when they select that for a nodetype that is out of their permission range, then use drupal form validation. This lets the form stay as it is, but if your check of the node types selected does not match up with the current user's roles then you can just fail their action before it reaches the next screen.

There is always more than one way, they may not all work for you but one of them should. If none of these match your need then please update the question.

  • The way is with the $form['field']['#options'], I guess. I am using Views Bulk Operations module, yes, and I see that the only option would be that, because I need to discriminate by userl role, I don't want to hide that option for the Admin, just for the Editor role (a special role). – Cesar Nov 4 '15 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.