Enable Node menu automatically I have a need to automatically create an Article node type each time a Basic-Page node type is created - I am using Rules successfully to achieve that effect.

My problem is a Menu link also needs to be created for each Article node created. This means the Provide a menu link checkbox needs to be automatically enabled in the process of creating each Article node - but it isn't.



The image above shows the checkbox I'm trying to automatically enable.

When creating an Article node directly, i:e not using Rules to create the new Article node, the box is checked and things work as normal.

I really need to find a solution which will enable the checkbox as I auto create my node types.
I don't think that it's possible through the UI. But here is how I would do programmatically:

function mymodule_node_presave($node) {
  if ($node-&gt;type == 'article') {
    $node-&gt;menu['enabled'] = 1;
  }
}


It would make your "Provide a menu link" checkbox as checked automatically.

You can also set all these values if you need to:



EDIT: I'm so sorry I forgot the node_save line in the code. Here is the correction:

function mymodule_node_presave($node) {
  if ($node-&gt;type == 'article') {
    $node-&gt;menu['enabled'] = 1;
    node_save($node);
  }
}