How to Display Different Menus to Logged in Users in WordPress?

WordPress allows you to show a single menu in a specific location in your theme. But if you wanted to show a different menu to logged-in users on your website, you need to add some code to your theme to add the functionality.

There may be plugins available for this but I prefer to code. When a few lines of code can solve a problem why use a plugin?

Maybe you can do it in many ways but I’ll show you the easiest ways.
first, register 2 or more menus

add_action( 'after_setup_theme', 'woo_reg_nav_menus' );
function woo_reg_nav_menus(){
    register_nav_menus( array(
        'logged-in-menu'    => 'Logged In Menu',
        'logged-out-menu'   => 'Logged Out Menu'

Then add the code below where you want to show the menus.

wp_nav_menu( array(
    'theme_location' => is_user_logged_in() ? 'logged-in-menu' : 'logged-out-menu'
) );