How do I hide  the main menu items? I have users who are the owners of some nodes, and each node has a menu link in the main menu. Users can only see the nodes they own, and they cannot see other user's nodes. 

The problem now is that the menu is displayed like in the following image, for all the users; it shows links for both the nodes owned by the current user, and the nodes the current user doesn't own.



I would like to display only the menu items corresponding to the nodes owned by the logged in user. How can I do this?
Drupal will hide menu items for paths that users don't have access to. But for this to work, it requires that the access callback for that menu item returns FALSE. If you handle access control in the menu callback instead, Drupal won't know that the user doesn't have access and will display the menu.

A solution would be to implement a custom access control module/function if you can't use any of the existing for the nodes.