latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

PHP Code to switch between menus per level?

Home › Forums › Community Forum › PHP Code to switch between menus per level?

This topic contains 4 replies, has 3 voices. Last updated by  Ethan 4 years, 2 months ago.

Topic Author Topic
Posted: Thursday Oct 18th, 2012 at 3:44 pm #28899

Hello,

I’m using a wonderful PHP code I found on the forum — I can’t recall now from which post — to show a different menu for guests versus logged in members.

'members' ) );
} else {
   wp_nav_menu( array( 'theme_location' => 'primary' ) );
}
?>

Is it possible to refine this code for if level 1, show X menu; if level 2, show Y menu… all through up to level 4? I’m not a PHP programmer so do not know how to write the code to include such conditionals.

  • This topic was modified 4 years, 2 months ago by  NONEOF YOURBUSINESS.
  • This topic was modified 3 years, 4 months ago by  NONEOF YOURBUSINESS.

List Of Topic Replies

Viewing 4 replies - 1 through 4 (of 4 total)
Author Replies
Author Replies
Posted: Thursday Oct 18th, 2012 at 4:22 pm #28903
Eduan
Username: Eduan
Moderator

Hello there,

Yes you would use the following:

<?php
if (current_user_is("s2member_level4")) {
	# Your menu for level 1 here
} elseif (current_user_is("s2member_level3")) {
	# Your menu for level 2 here
} elseif (current_user_is("s2member_level2")) {
	# Your menu for level 3 here
} elseif (current_user_is("s2member_level1")) {
	# Your menu for level 4 here
} else {
	Your menu for non logged-in users here
}
?>

Would that work for you?

Hope this helps. :)

Posted: Thursday Oct 18th, 2012 at 5:08 pm #28905

Yes! That’s just what I needed! Set up my menus and they all seem to be working great! =) Much appreciation.

Posted: Thursday Oct 18th, 2012 at 6:06 pm #28922
Eduan
Username: Eduan
Moderator

No problem, glad I was able to help. :)

Posted: Friday Nov 2nd, 2012 at 2:50 am #30393
Ethan
Username: Ethan2130

Hi NONEOF YOURBUSINESS,

Could you please help me out by telling me where you are putting your php code that shows a different menu to guests vs logged in members.

Thanks heaps, I am having real trouble finding out how to show a different menu to my members.

Ethan

Viewing 4 replies - 1 through 4 (of 4 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.