function node_access_example_form_alter

Same name in other branches
  1. 7.x-1.x node_access_example/node_access_example.module \node_access_example_form_alter()

Implementation of hook_form_alter()

This module adds a simple checkbox to the node form labeled private. If the checkbox is labelled, only the node author and users with 'access private content' privileges may see it.

Related topics

File

node_access_example/node_access_example.module, line 197

Code

function node_access_example_form_alter(&$form, $form_state) {
    if ($form['#id'] == 'node-form') {
        $form['private'] = array(
            '#type' => 'checkbox',
            '#title' => t('Private'),
            '#description' => t('Check here if this content should be set private and only shown to privileged users.'),
            '#default_value' => isset($form['#node']->private) ? $form['#node']->private : FALSE,
        );
    }
}