I want to be able to hide the 'My account' button when users are logged out and I want to be able to hide the 'Registration' button when users are logged in.

How would I go about doing this? I'm still a amatuer at WordPress and I'm still learning, this is what I have so far in my nav-menus.php file.

if( is_user_logged_in() ) {
    wp_nav_menu( array( 'My Account' => 'logged-users' ) );
} else {
    wp_nav_menu( array( 'Registration' => 'not-logged-users' ) );

I know this isn't correct, but I would love some help with it, please let me know if I'm missing any information.

enter image description here

  • You may need to create a custom walker function. There doesn't seem to be anything you can pass into the wp_nav_menu() function to exclude specific menu items. – WebElaine Feb 12 at 14:45
  • 1
    Hey Saint Louis, This question has been asked many times. Wpbeginner has a few plugin ideas and on this stack there are several question with answers. I would go with the idea of replacing the whole menu (not just items). wordpress.stackexchange.com/questions/233667/… – rudtek Feb 12 at 15:28

These are the plugins I use most often to show/hide menu items based on user role or weather the user is logged in or out:

https://wordpress.org/plugins/user-menus/ - Simple and intuitive.

https://wordpress.org/plugins/conditional-menus/ - For more advanced conditions and flexibility.

I also just found this one:

https://wordpress.org/plugins/if-menu/ - I have not tested it but it has better reviews and was updated more recently than my first suggestion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.