Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

Here the idea is to avoid defining dozens of roles to account for delicate permission requirements of users.

Say, on a certain node that has 100 fields, a webmaster may eventually need to define several hundreds of permission sets, many of them are needed for very few users on and ad hoc manner. Being able to define field permissions for particular users gives the webmaster ultimate flexibility and avoids insane proliferation of roles.

I appreciate your hints about this possibility.

share|improve this question
Have you tried Field Group module? i hope you can specify a permission to a set of fileds. Giv a try and please let me know the status. – Nikhil M Nov 23 '12 at 4:00

1 Answer

up vote 3 down vote accepted

You can manage this with #access if you're using hook_form_alter to make and manage the fields.

Description: Whether the element is accessible or not; when FALSE, the element is not rendered and the user submitted value is not taken into consideration.

Another idea is get help of access callback in hook_menu

"access callback": A function returning TRUE if the user has access rights to this menu item, and FALSE if not. It can also be a boolean constant instead of a function, and you can also use numeric values (will be cast to boolean). Defaults to user_access() unless a value is inherited from the parent menu item; only MENU_DEFAULT_LOCAL_TASK items can inherit access callbacks. To use the user_access() default callback, you must specify the permission to check as 'access arguments'

The idea is to make a function that resolves permissions for individual user for certain pages.

share|improve this answer
Is #access integrated in any module, and if not, what is the best way to implement it? Thanks – alfish May 22 '12 at 9:16
Make a custom module to implement #access. i.e. function mymodule_form_alter(&$form, $form_state, $form_id) { $form['field_YOUR_FIELD_NAME']['#access'] = FALSE; } add if statements where needed. – Mike May 22 '12 at 11:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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