How to make nodes to be aware that they were added to menu programatically I'm adding nodes to menu programatically by custom PHP snippet in Rules. The problem is that nodes aren't aware of this - so the option "Provide a menu link" is unchecked in them, even if their menu-item exists. I cannot find anything relevant in $node object. How to fix this?

My code is:

$node_path = "node/" . $node-&gt;nid;
$node_alias = drupal_get_path_alias($node_path);
$menu = menu_load_links('main-menu');

foreach($menu as $key=&gt;$value) {
    if($node_alias == $menu[$key]['link_path'] || $node_path == $menu[$key]['link_path']) {
        return;
    }
    if($menu[$key]['link_title'] == $node-&gt;field_rok['und'][0]['value'] &amp;&amp; $menu[$key]['link_path'] == "&lt;nolink&gt;") {
        $menu_year = $menu[$key]['mlid'];
    }
    if($menu[$key]['link_path'] == "archiwum") {
        $archiwum_plid = $menu[$key]['mlid'];
    }
}

if(!isset($archiwum_plid)) {
    return;
}

if(!isset($menu_year)) {
    $item = array(
        'link_path' =&gt; '&lt;nolink&gt;',
        'link_title' =&gt; $node-&gt;field_rok['und'][0]['value'],
        'menu_name' =&gt; 'main-menu',
        'plid' =&gt; $archiwum_plid,
        'hidden' =&gt; 0,
    );
    // menu_edit_item_validate(array(), $item); Drupal doesn't recognize this function in this place (Rules), don't know why... :/
    $menu_year = menu_link_save($item);
}

$item = array(
    'link_path' =&gt; $node_alias,
    'link_title' =&gt; $node-&gt;field_numer_w_roku['und'][0]['value'] . '/' . $node-&gt;field_rok['und'][0]['value'] .' (' . $node-&gt;field_numer['und'][0]['value'] . ')',
    'menu_name' =&gt; 'main-menu',
    'plid' =&gt; $menu_year,
    'hidden' =&gt; 0,
);

// menu_edit_item_validate(array(), $item);
menu_link_save($item);

menu_rebuild();
Got it - I had to use drupal_get_normal_path($node_alias) on path added to menu. I hope that will be helpful for someone.