I created a custom module that hides a field in a content type editing screen from the user and simultaneously auto-selects a value for that field for the user. It works great for the admin role but for some reason my other user's who are able to login and who have permission to edit the content type don't get this functionality applied. They still see the field and can still select a value for it.
Anyone know how to make the permissions for a custom module apply to ALL users?
Here's my module code:
/**
* @file
* Auto saving to a term reference field.
*/
/**
* Implementation of hook_form_alter().
*/
function seven_form_resource_node_form_alter(&$form, &$form_state, $form_id) {
hide($form['field_icon']);
}
/**
* Implementation of hook_node_presave().
*/
function grouphideandselect_node_presave($node){
//Condition for particular content type
if($node->type == 'resource'){
$icon_ary = array();
//Array to map category with icon given as Category=>Icon
$field_type_to_icon = array(1 => 1,2 => 1,3 => 1,4 => 2,5 =>
2,6 => 2,7 => 2,8 => 6,9 => 6,97=>6,98 => 6);
$category = $node->field_type['und'];
foreach($category as $k=>$c){
$icon = $field_type_to_icon[$c['value']];
if(!in_array($icon, $icon_ary)){
$icon_ary[] = $icon;
$node->field_icon['und'][$k]['tid'] = $icon;
}
}
}
}
$form['field_icon']['#access'] = FALSE;
? Also your hooks seem a bit off, can't figure out if your module's name isgrouphideandselect
orseven_form
. The thing withhide()
is it's more of a render thing, and can have unexpected behaviors. I'm not really sure why it's behaving like that for you (could be cache, most likely), but this has NOTHING to do with permissions