We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6531
    • 154 Posts
    I am trying to use MemberCheck (with Revo) but it gives me ’group could not be found’, even though there is such a group.

    Anyone?

    Thanks
      • 3749
      • 24,544 Posts
      Try changing the test in the snippet to:

      if ($modx->user->isMember('groupname')) {
      }


      Of course the user will have to log in first.
      Just putting the login snippet on the page and redirecting to the current page is probably a better method.
        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
        • 6531
        • 154 Posts
        Thanks!
          • 15796
          • 24 Posts
          hmm, sounds like I got the exact same issue:
          Membercheck keeps returning
          "The group NewsEditors could not be found..."
          while it does exist. I copy-pasted the name from group in the snippet call and tried to create a group based on the name in the error message(group with that name already exists) so I’m pretty dam sure I typed it correctly.

          I’m using 1.2-beta2 so perhaps that’s why I can’t retrieve the piece of code you mentioned.
          That or I’m just not sure what you mean by

          Try changing the test in the snippet to:
          if ($modx->user->isMember('groupname')) {
          }
            • 3749
            • 24,544 Posts
            I can’t see any packages in Package Manager now, so I can’t give you a definitive answer. Basically, the suggestion was to replace the if statement in the snippet that tests for group membership with the line above.

            I’m not sure if that would apply to the current version or not.
              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
              • 15796
              • 24 Posts
              that’s where you can download it
              http://modxcms.com/extras/download/908/939
              you just have to upload it to the packages folder and in package manager set it to search for local packages. it then will work like a normal package.

              so I guess once I discover this line there are 2 options:
              either it works when I change the code, or it doesn’t
              if it still doesn’t I guess it has something to do with my group, but what if it does work when I change the code? what can I conclude then? that there is an error in the code? or that I call the snippet incorrectly?
                • 3749
                • 24,544 Posts
                MemberCheck was obviously written for Evolution. It has been updated for Revolution, but only partially. It uses some deprecated functions (e.g. isMemberOfWebGroup()) and it doesn’t use xPDO.

                What, exactly are you trying to do? There’s probably a much faster way to do it with a custom snippet.
                  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
                  • 15796
                  • 24 Posts
                  Well, I just want to check if the user is part of the NewsEditors group. If he is, I want a certain chunk displayed and if he’s not a different chunk.
                  I first tried the Personalize package but that does not check for a group.
                    • 3749
                    • 24,544 Posts
                    Try this:

                    [[!EditorCheck]]


                    <?php
                    
                    /* EditorCheck snippet */
                    
                    $output = $modx->user->isMember('NewsEditors') ? $modx->getChunk('EditorChunk') : $modx->getChunk('nonEditorChunk');
                    return $output;


                    Or, if you need to send the chunk names and the group name in the snippet:

                    [[!MemberCheck? &group='NewsEditors' &yesChunk=`SomeChunk` &noChunk=`SomeOtherChunk`]]


                    <?php
                    
                    /* MemberCheck snippet */
                    
                    $output = $modx->user->isMember($group) ? $modx->getChunk($yesChunk) : $modx->getChunk($noChunk);
                    return $output;



                      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
                      • 27106
                      • 147 Posts
                      I've had the same problem. modx.com is rather unclear on MemberCheck's viability for Revo. My advice FWIW, as of now: don't use it. Use Bob's code instead.
                        David Walker
                        Principal, Shorewalker DMS
                        Phone: 03 8899 7790
                        Mobile: 0407 133 020