We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6926
    • 41 Posts
    Hi,
    I have a page custom coded for Modx but the programmer who was working on it could not work because of his personal family issues. Now I am in a situation where I want to get this thing working but I can’t.

    The situation is - there is a page on our site which can only be accessed by selected web users. In the snippet I have option to add user ids in the allowed web user’s array vairable. But it also asks me to allowed admin user ids too.

    And in the other page - it checks for condition if admin user or web user from array is present - then only allow user to access. But I do not know it allows me only if admin from manager and web user both login at the same time.

    Following is part of the code:

    $admin_allowed_to_edit_array = array('1','2');
    $webuser_allowed_to_edit_array = array('2','122');
    
    if(isset($_SESSION['mgrValidated']) && (in_array($_SESSION['mgrRole'], $admin_allowed_to_edit_array))  || isset($_SESSION['webValidated']) && (in_array($_SESSION['webInternalKey'], $webuser_allowed_to_edit_array))){
    
    $output ="";


    I do not mind if someone want to access admin panel too. or if someone can do it for some fees - then also no issues at all.

    Thanks
    Deep
      Deep Ganatra
      Web1 Solutions
      • 7923
      • 4,213 Posts

      if((isset($_SESSION[’mgrValidated’]) && in_array($_SESSION[’mgrRole’], $admin_allowed_to_edit_array)) || (isset($_SESSION[’webValidated’]) && in_array($_SESSION[’webInternalKey’], $webuser_allowed_to_edit_array))){


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 6926
        • 41 Posts
        Thanks it fixed the problem but now the issue is - it just checks for the last user ID in the array. When I am logging in using userid 2, it does not allow me to view page but when I login using userid 122, it works fine.

        Any ideas?
        Deep
          Deep Ganatra
          Web1 Solutions
          • 7923
          • 4,213 Posts
          webusers or manager users? does $_SESSION[’mgrRole’] really hold the ID of a manager user?


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 6926
            • 41 Posts
            Hi,
            Sorry for the confusion, let me re frame my sentence.

            Now the issue is - it just checks for the last user ID in the array. When I am logging in using web userid 2, it does not allow me to view page but when I login using web userid 122, it works fine.

            Ref code:
            $webuser_allowed_to_edit_array = array('2','122');


            Thanks
            Deep
              Deep Ganatra
              Web1 Solutions