Jump to content
Sign in to follow this  
sruefer

Show user role specific navigation menu

Recommended Posts

sruefer

Hi, I am trying to show different navigation for users depending on their roles and capabilities. On a different theme (Swatch, from Woo Themes) I could implement that by modifying the header.php file, essentially replacing the original navigation and writing PHP conditionals, e.g.

	if (current_user_is("Subscriber")){
	    wp_nav_menu('menu' => 'User Menu');  // Specific User Menu created with custom menus
	}
	elseif (current_user_is("Administrator")) {
	    wp_nav_menu('menu' => 'Admin Menu');  // Other specific Menu created with custom menues
	}
	

but I cannot get this to work with PageLines. I am using the Base theme and I copied the nav section over from the parent theme. Then I modified the section.php file to add a menu name depending on user role, but it does not work. I think the problem is that I do not want to assign a theme location (because then I have to select specific custom menu). Any idea what I can do to make that work? Thanks a lot, Steffen

Share this post


Link to post
Share on other sites
sruefer
Hi Catrina, I think I found the solution; I modified the function "section_template()" in the section.php file of the nav section. Below is the modified function code: [code] function section_template() { $container_class = ( ploption('hidesearch') ) ? 'nosearch' : ''; printf(''; } [/code] Basically what I did is: - Created $menu parameter, assigning the custom menu name depending on user role (I am using the s2member plugin, which creates additional roles). - Removed 'theme_location' from wp_nav_menu - Added 'menu' to wp_nav_menu That seems to work for now :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×