Show 'log in' in user menu when not logged in I'm asking myself, where is the code that hides "My account" &amp; "Log out" in the user menu? Just curious, to learn from that code. Any way to know where to search if you want to know something like this?

I added a "Log in" link to this menu, and I want to hide this when nobody is logged in.
You can add a menu link to user/login, the access callback of that verifies that it is only shown to anonymous users. Just like user/logout is only visible for logged in users.

The definition of these callbacks() are, as mentioned in the other answer, in user_menu()