For example, you want to show logged-in users a link to their profile and a link to sign in or register for users who are not logged in. In this article, I will show you, how to change menu after login or show different menus to logged-in users in two(2) ways in WordPress.
Way 1: Using Nav Menu Roles plugins – This plugin will allow you to display your menu items based on the user role on your WordPress site. If you have a link in the menu that you only want to show to your vendors only, you can toggle that on the Menu page. Example :
Way 2: Using manual code:
- In WordPress even if your theme has one menu location, you can still create multiple menus for the same location.
- Go to Appearance » Menus, create two menus logged-in and logged-out.
- After creating the menus, add this code to your theme’s functions.php file.
123456789101112function my_wp_nav_menu_args( $args = '' ) {if( is_user_logged_in() ) {$args['menu'] = 'logged-in';} else {$args['menu'] = 'logged-out';}return $args;}add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
That’s all you will see that you are logged-in visitors will see the logged-in menu and non-registered or logged-out users will see a different menu. This method allows you to create two different menus for your users so that you can freely update your menus for logged-in or logged-out users. Example:
I hope this article helped you show different menus to logged-in users in your WordPress site. For questions and feedback please leave a comment below.
Hi Dear, are you in fact visiting this web page regularly, if so afterward you will without doubt get nice knowledge.