We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1778
    • 659 Posts
    Hello

    I experienced this behavior today with the output modifer "memberof" which checks if the user is a member of the specified group(s).

    [[+modx.user.id:mo=`group1`:then=` Member of Group 1`:else=`not member`]]
    

    This piece of code works (pretty) fine but when the logged user does not belong to the group "group1" I have this error displayed (screen capture attached)
    Parse error: syntax error, unexpected ')' in C:\wamp\www\mysite\core\model\modx\filters\modoutputfilter.class.php(163) : eval()'d code on line 1
    


    Any idea about this ?
    Cheers [ed. note: anso last edited this post 14 years, 7 months ago.]
      • 3749
      • 24,544 Posts
      I couldn't make it work either and I also couldn't get it to work with the If snippet.

      This worked:

      [[!GroupMember? &groups=`Administrator,group1` &yes=`Is a Member` &no=`Not a member`]]


      /* GroupMember snippet */
      $groups = explode(',', $scriptProperties['groups']);
      
      if ($modx->user->isMember($groups) ) {
        return $scriptProperties['yes'];
      } else {
        return $scriptProperties['no'];
      }
      


      Note: The &groups property could be &groups=`Group1` and you could modify the snippet so that the &yes and &no properties contained the names of chunks to show:

      if ($modx->user->isMember($groups) ) {
        return $modx->getChunk($scriptProperties['yes']);
      } else {
        return $modx->getChunk($scriptProperties['no']);
      }




      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 14 years, 7 months ago.]
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 1778
        • 659 Posts
        Hello Bob
        Thanks for your reply. I did a snippet (very close to yours in fact) to solve my problem....
        And now I'm sure it's a bug with the output modifier, and not a mistake I've done...
        Chhers
          • 3749
          • 24,544 Posts
          Could you please report it at http://bugs.modx.com so it will get fixed?


          ---------------------------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
          MODX info for everyone: http://bobsguides.com/modx.html
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 1778
            • 659 Posts
            Done ! Bug #7229...
            Cheers
              • 3749
              • 24,544 Posts
              Thanks! tongue



              ---------------------------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
              MODX info for everyone: http://bobsguides.com/modx.html
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 38878
                • 255 Posts
                I guess no update on this bug. I checked tracker and no resolution.