Hide page link in main menu from anonymous users

No plugin or PHP code is needed to do this. If you look at your HTML body class, you will see that WP helpfully adds the class of “logged-in” for any users who are registered and logged into the site.

With this info along with the class name you give for the particular menu link you want to hide/show, you can draft a CSS rule that will hide that.

In your menu settings, first turn on CLASS field by going to the top right of your screen and clicking on “screen options” and check the box for CLASS fields. This will now show a class field for each menu item in your menu.

So for the menu you want to show/hide, add a class name such as “hide”.

Then in your theme’s CSS, you can add the following:

.menu li.hide { display:none; }
.logged-in .menu li.hide { display:block; }

So the above CSS says to hide the menu link with the class name of “hide” and if body class has “logged-in”, then show it.

Of course you may need to change the CSS classname to suit your theme’s CSS class name. For example yours may not be “.menu”.