I am trying to disable the 'Create new revision option' in each existing nodes programmatically.
I tried with below codes but it was not working.
$results = db_select('node', 'n')
->fields('n', array('nid','vid'))
->execute();
foreach ($results as $result) {
$node = node_load($result->nid);
// Disabling the Create new revision option
$node->revision = FALSE;
node_save($node);
}
Can anyone help me on this? Thanks.

Comments

jaypan’s picture

Try setting $node->revision to 0 (zero) instead of false.

Contact me to contract me for D7 -> D10/11 migrations.
Or anything really. I'm friendly, and open to work or conversation.

aswinik’s picture

It got worked by writing a hook_form_alter function in the respective module. Added following lines to the function.

$form['revision_information']['#disabled'] = TRUE;
$form['revision_information']['revision']['#default_value'] = 0;