Give help. Get help.

  • # September 22, 2009 at 4:05 pm

    I am trying to figure out the best solution to this problem – but not being hot on PHP, i could do with a bit of help.

    I’m building a site for WordPress.

    the site will have a number of different users who will have different levels of access to read pages. So ‘User Group 1’ might have access to view page 1, 2, 3 and 4. ‘User Group 2’ might have access to page 1, 4, 5 and 6.

    What i am trying to figure out is – once ‘user group 1’ logs in and gets redirected to the index page i want to control which tabs are displayed in the nav bar.

    – if user group 1 – display tabs 1, 2, 3 and 4
    – if user group 2 – display tabs 1, 4, 5, 6

    (however, there may be a large number of different user groups / access levels.)

    and so on.

    Is this achieved with ‘switch’ ?
    could someone point me in the right direction please.

    many many thanks for your help.

    # September 22, 2009 at 11:08 pm

    can you make the many different navs and then put them in different files and include them? something like

    if($group == 1)

    Maybe store your groups in an array and make the nav available to the groups in that array?

    # September 23, 2009 at 2:50 am

    many thanks – i will have a look at this solution. is this the most logic solution?

    # September 27, 2009 at 12:15 pm

    Yeah that solution seems to be very logical. You might want to consider storing the variable in a PHP session, so that you can reuse it. The best way would be to have the logical expression (the if statement) on the login page, and then a variable is set that contains the path of the navigation, so…

    if($usergroup == 1)
    $_SESSION[‘nav-path’] = “nav/nav1.php”;
    $_SESSION[‘nav-path’] = “nav/nav2.php”;

    And then when your user visits a page…

    < ?php include($_SESSION['nav-path']) ?>

    This solution will make it more manageable in the long run. Hope this helps.


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

You must be logged in to reply to this topic.