3

I'm writing a custom ticketing system module for my company and I would like certain form elements disabled based on permissions. Is there a way I can do this without needing to make two separate forms (ex: user form, admin form)

I know for the items array in a menu hook, you can just set 'access arguments.' Preferably I'd like to just use the existing permissions I've already created for my module or even make it role specific.

1 Answer 1

5

You can use the FAPI #access property:

$form['some_element']['#access'] = user_access('some permission');
1
  • Ah, thank you. I was skimming through the documentation and didn't quite get how I would implement the user_access();. Makes sense now.
    – Dave_R
    Commented May 1, 2012 at 19:46

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.