We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51360
    • 6 Posts
    I am a little bit confused...
    I have some resources, which are Hidden From Menu, but I will make them accessible for a specific user (admin).
    After an user is logged, I store his 'user_id'. I have created simple snippet which decides, if this user is admin

    isSU Snippet:
    <?php
        if ( $_SESSION['user_id'] == 7 ) return 1;
        else return 0;


    and I use this snippet in WayFinder in the following way:
    [[Wayfinder? 	
    ...
         &ignoreHidden=`[[!isSU]]`
    ...
    ]]


    which is not working. When I set maualy &ignoreHidden=`1` or `0`, everything works fine. I have also checked, if my snippet returns 1 or 0...
    Please, there has to be something very fundamental, why this happens to me...
    I will be grateful for any advice

    This question has been answered by ottogal. See the first response.

    [ed. note: quantorum last edited this post 10 years, 11 months ago.]
    • discuss.answer
      • 22427
      • 793 Posts
      <?php
          if ( $_SESSION['user_id'] == 7 ) return 1;
          else return 0;
      should be
      <?php
      if ( $_SESSION['user_id'] == 7 ) {
          return 1;
      } else {
          return 0;
      };

      And try to call Wayfinder uncached:
      [[!Wayfinder? 
        • 51360
        • 6 Posts
        This solved my problem
        Quote from: ottogal at Nov 12, 2015, 12:13 PM

        And try to call Wayfinder uncached:
        [[!Wayfinder? 
        Thank you for your quick response
          • 4172
          • 5,888 Posts
          if this is a MODX-user, this should work, too:

          return $modx->user->get('id')==7 ? 1 : 0;
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!