I've setup a site for a client I want them to have access to edit content, but some of the permissions grant too much control for my liking. Can someone give me a way to be a bit more selective with permissions. These are my areas of interest.

  1. I have a custom block which contains 2 editable fields, To allow access I have to grant access to Administer Blocks, which give the user access to reposition the block, I would like this to disabled, and also the Regional and Visability settings to be disabled.

  2. When editing a Basic Page node, I have an image field which I dont want the user to be able to adjust.

Any clever people out there know the answers?

1 Answer 1


The only way I can think of is to implement hook_form_alter() and add the "#access" property to the form fields you don't want to be accessible from the user.
Normally you should use code similar to the following one, but every function that returns FALSE when the current logged-in user should not access the form field would work too.

$form['form_field']['#access'] = user_access("access form_field");

The permission the code checks can be any of the permissions the module implements, or other modules implement.

  • Thank you, that does seem the most likely solution. Would you know where I can locate the specific form_field values for these areas I'm interested in? This always seems to be the area I get stuck on. Commented Sep 9, 2011 at 14:26
  • You need to look at the source code of the module for that: Knowing the path of the page you are watching, you can know which module is showing that page by looking at all the hook_menu() implementations of the enabled modules; from that, you can know which function is outputting the form, and where the function is located.
    – apaderno
    Commented Sep 9, 2011 at 14:43
  • Thanks yeah, I looked though the modules and found pretty much everything I needed. I did have trouble with some areas, but I guess I still need more experience with Drupal. Commented Sep 12, 2011 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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