If you set up a membership website, an online forum or an e-commerce site, you will have a lot of outside users who have registered the accounts on your site. In this case, it is possible that you want to show different navigation bars to different users. For instance, you can showcase the personalized navigation to logged-in users so as to take them to the special pages easily, such as their profile page and the forum area. As for visitors who do not log in, you can display the menu items of registration or login directly.
Frankly speaking, it is not necessary to maintain the same navigation to all your visitors. Instead, the personalized and custom ones can tailor to your users differently. Here, we’d like to introduce three methods about how to show custom WordPress navigation bar to different users. By doing so, people who come with different user roles, who have logged in or have not logged in, who check different site pages or who access your site using different viewing devices can be displayed with different navigation bars.
Method 1 – Show Custom WordPress Navigation Bar Manually
If you are conformable of modifying the function.php file of your current theme, you can consider the manual option for doing so. Here, you do not need to install some extra plugins, but leverage a few lines of coding stuff.
Here, you firstly need to create two or more different navigation bars for different users. For this, you can click the Create A New Menu link from the WordPress Menus section.
After that, you can give the new navigation bars the names. In our example, we name our bars as Logged-In Users and Logged-Out Users. Surely, you can name the navigation bars based on the real situations. And then, you need to add the menu items from the left column that lists all the pages.
As you have already created the custom navigation bars for different users, you can open and edit your function.php file to enter the following lines of code. Note that this coding example is suitable if you create two bars that are named as Logged-in and Logged-out. You can modify the related values if you choose some other menu bar names.
That’s it. Now, people who have logged in and who haven’t logged in will see different navigation bars from your site.
Method 2 – Utilize the Nav Menu Roles Plugin
If you do not want to work with the coding stuff, you can consider the utilization of Nav Menu Roles plugin. With this tool, you do not need to create multiple navigation bars. Instead, you simply need a single bar that comes with multiple menus. Here, you can use this special plugin to hide or to showcase the specific menus for different users.
There is no need for you to set up for it. In this case, you can directly go to the Menus section by hitting the Appearance > Menus button. Now, you can click each of your menu tabs and navigate to the Display Mode section.
Here, you can choose to showcase this menu tab to all the common visitors, to logged out users only or to logged in users only.
In addition, if you want it to display for logged in users, you also need to restrict this menu item to some special user roles.
This way, your site visitors can check different navigation bars that come with personalized menu items.
Method 3 – Utilize the If Menu Plugin
The If Menu plugin is a little bit similar to the previous plugin. With the extra functionality added into the Menu items, you can hide or show the menu stuffs based on some conditional statements.
Here, you simply need to have it installed and click the Menus button from the tab of Appearance. Now, you can target each menu item of your main navigation bar. In addition to the options of Navigation Label, Title Attribute and CSS Classes, you now can find a new checkbox of Enable Conditional Logic. Just click it.
Here, we need to mention that you may fail to find any conditional statement after ticking this special box. If so, you should save the settings firstly by clicking the Save Menu button.
Now, you can consider the conditional logic of showing this item or hiding this item. In addition, you have the freedom to add some extra conditions. For instance, you can hide or show the menu item if the user is logged in or is the admin. Also, you can display or conceal the specific item when people access the homepage or when they check your site using the smart phone. Another great highlight of this plugin is that you can enable more than one condition as you want.
Now, you can save the settings so that you can showcase the custom WordPress navigation bar to different users.