Displaying my content for two defined user groups

Wednesday, November 4, 2015

I have two user groups - Admin (A) and Moderator (M) - and a navigation menu. Some of the links are only to be visible for the Admin, while the others are visible to both. Here's my current code:



<? if($_SESSION["LogedInAdminId"] && $_SESSION['AdminStatus']=="M") { ?>
<ul>
<li>...</li>
<li>...</li>

<? if($_SESSION["LogedInAdminId"] && $_SESSION['AdminStatus']=="A") { ?>
<li>...</li>
<li>...</li>
<? { ?>

</ul>
<? } ?>


Currently, the menu is only shown for moderators because of the first line:



<? if($_SESSION["LogedInAdminId"] && $_SESSION['AdminStatus']=="M") { ?>


So I tried to include the Admin group to is like so:



<? if($_SESSION["LogedInAdminId"] && $_SESSION['AdminStatus']=="M" || "A") { ?>


However, this breaks the code and displays the menu for everyone - Admin, Mod, guests, etc. What would be the correct way of including two user groups?

0 comments:

Post a Comment