Drupal - Create a new revision automatically on edit

To enabled automatic revision creation go to the content type page (admin/content/node-type) and select edit for whatever content type you wish to have revision created automatically.

Under the workflow fieldset there's going to be an option "Create new revision" make sure you check that box and save your content type settings.

Now under your permissions (admin/user/permissions) be sure to not to give your users the "administer nodes" permission. This will prevent them from overwriting that option.


There's a few different ways to do this, but assuming you want to do it without disabling the administer nodes permissions for users, probably the easiest way is to just turn off access to the Create new revision checkbox by creating a custom module that implements hook_form_alter():

function sandbox_form_alter(&$form, &$form_state, $form_id) {
  // Node forms have an ID of the form CONTENTTYPE_node_form: only modify those
  if (strstr($form_id, '_node_form') === FALSE) {
    return;
  }

  if (isset($form['revision_information'])) {
    $form['revision_information']['revision']['#access'] = FALSE;
  }
}

This way, users don't have the ability to change the default value of the checkbox, which is set on the settings page for each content type.

Tags:

Nodes