You are here

function content_permissions_form_alter in Content Construction Kit (CCK) 6

Implementation of hook_form_alter(). Remove inaccessible fields from node display.

File

modules/content_permissions/content_permissions.module, line 16

Code

function content_permissions_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
    $type = content_types($form['type']['#value']);
    foreach ($type['fields'] as $field_name => $field) {
      if (isset($form[$field_name])) {
        $form[$field_name]['#access'] = user_access('edit ' . $field_name);
      }
    }
  }
}