Creating Different Menus for Different User Roles

Tonight I created a custom admin bar that gave our admins quick links to the most used features. The problem is that each menu and corresponding links were viewable by all registered users, who cannot access these links and get an error code when trying to.

So here is my question:

How do I create different menus for different user roles? I want each user to have custom menus for that correspond to what they are allowed to access on the site.

Thanks!

  • Predrag Dubajic

    Hey @Pdca Admin,

    Hope you're doing well today :slight_smile:

    Unfortunately this is not possible out of the box but it should be doable with using simple mu-plugin that will hide certain menus from certain user roles with CSS code.
    Can you create the menus that you want to show, keep the access to your site active and write here which menu should be visible by which role, and I will attach a file for you to do this?

    If you want to try doing this yourself this is example code you can start with:

    <?php if (!is_admin()) { ?>
    	<style type="text/css">
    		#wp-admin-bar-ub_admin_bar_709 {
    			display: none;
    		}
    	</style>
    <?php } ?>

    Best regards,
    Predrag