Skip navigation
Currently Being Moderated

Show / Hide content based on access levels (php)

Apr 12, 2012 6:02 AM

Tags: #php #show/hide_field

I have a region of a web page that is visible only to logged in users with the access level 'level1' - I want to amend this code and add a second user access level 'level2'.


So basically I want users with access 'level1' and 'level2' to see 'X' content.


Here's the code....


<?php if (isset($_SESSION['MM_UserGroup']) && $_SESSION['MM_UserGroup']=='level1'){ ?>


'content here'


<?php } ?>



I tried amending the code to the following but without luck:


<?php if (isset($_SESSION['MM_UserGroup']) && $_SESSION['MM_UserGroup']=='level1,level2'){ ?>



Any help would be appreciated!

  • Currently Being Moderated
    Apr 12, 2012 11:14 AM   in reply to Wookie



    Are you trying to test for users that are in a group called 'level1,level2' ?  Or testing if the user is in either level1, or level2? If the latter, then obviously your code won't work. You would need to check for either condition.


    <?php if (isset($_SESSION['MM_UserGroup']) && ($_SESSION['MM_UserGroup']=='level1') || $_SESSION['MM_UserGroup']=='level2')){ ?>

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points