We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I think I see the problem. In order to update the registration, ClassExtender removes the extension package first. Unfortunately, removeExtensionPackage() is missing a sanity check and assumes that the setting exists so it's crashing PHP before the setting can be created.

    I'll create a workaround.
      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
      • 26388
      • 103 Posts
      Quote from: BobRay at Jun 06, 2014, 10:16 PM
      I think I see the problem. In order to update the registration, ClassExtender removes the extension package first. Unfortunately, removeExtensionPackage() is missing a sanity check and assumes that the setting exists so it's crashing PHP before the setting can be created.

      I'll create a workaround.

      Interesting. Yeah, I assumed based on the guide that the setting was supposed to be created behind the scenes. Still, I think it would be good to mention in the guide to check and insure it was created as well as what to do if it's not there...

      On another note, is there an easy way to change the GetExtUsers snippet to simply list all users within a specific user group? It seems or at least the only way I've gotten the snippet to list users is to use the
      &where=`{"Data.firstName:=":"Michael"}`
      to search a specific user attribute. If I run the snippet without any settings like so: [[!GetExtUsers]] it returns nothing. Is this normal and how it's supposed to work?
        • 3749
        • 24,544 Posts
        I just released a new version of ClassExtender that doesn't care if the setting is there or not.

        Susan has filed a bug report on the missing setting, and I added a note about a sanity check for removeExtensionPackage(), so the user should never have to worry about it again. wink

        Unfortunately, user group data is somewhat complex and it's not easy to work it into GetExtUsers in its fastest form. I'll probably add it eventually.

        Here's a quick way to get that functionality in GetExtUsers, though it will slow things down a little when you use it, since it's not the fastest method. Let me know how much it slows things down when you use it.

        Add a &groups property to the snippet tag:
          &groups=`group1,group2` 


        Add this at line 60 of the GetExtUsers snippet:

        $groups = $modx->getOption('groups', $sp, null);
        if (!empty($groups)) {
            $groups = explode(',', $groups);
        } 


        And change line 81 from:

        foreach ($users as $user) {


        to:

        foreach ($users as $user) {
           if (! empty($groups)) {
               if (! $user->isMember($groups)) continue;
           }
          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
          • 26388
          • 103 Posts
          Quote from: BobRay at Jun 07, 2014, 02:40 PM
          I just released a new version of ClassExtender that doesn't care if the setting is there or not.

          Susan has filed a bug report on the missing setting, and I added a note about a sanity check for removeExtensionPackage(), so the user should never have to worry about it again. wink

          Unfortunately, user group data is somewhat complex and it's not easy to work it into GetExtUsers in its fastest form. I'll probably add it eventually.

          Here's a quick way to get that functionality in GetExtUsers, though it will slow things down a little when you use it, since it's not the fastest method. Let me know how much it slows things down when you use it.

          Add a &groups property to the snippet tag:
            &groups=`group1,group2` 


          Add this at line 60 of the GetExtUsers snippet:

          $groups = $modx->getOption('groups', $sp, null);
          if (!empty($groups)) {
              $groups = explode(',', $groups);
          } 


          And change line 81 from:

          foreach ($users as $user) {


          to:

          foreach ($users as $user) {
             if (! empty($groups)) {
                 if (! $user->isMember($groups)) continue;
             }

          Thank you! I'll try this out and see how it performs. The site this is getting applied to is small and basically getting used to display a small business directory. So performance might not be hampered all that much as there won't be a ton of records to go through.
            • 3749
            • 24,544 Posts
            I think if you leave out the &where property, you'll get all users in the group(s).
              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
              • 26388
              • 103 Posts
              So as I experiment with this I was trying to use pdoTools (pdoUsers) to list the users - do you know off-hand why it doesn't return the fields in the ext_user_data table even though the class_key is set to extUser?
                • 3749
                • 24,544 Posts
                It's because there's no code in pdoUsers to get that data (which is in a separate table that pdoUsers doesn't know about).

                If you were only getting one user, you could use the SetUserPlaceholders snippet, but if you want many you'd need to add the code to pdoUsers, use getExtUsers, or write 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
                  • 38705
                  • 101 Posts
                  Quote from: BobRay at Jun 07, 2014, 02:40 PM

                  ...
                  Add this at line 60 of the GetExtUsers snippet:

                  $groups = $modx->getOption('groups', $sp, null);
                  if (!empty($groups)) {
                      $groups = explode(',', $groups);
                  } 


                  And change line 81 from:

                  foreach ($users as $user) {


                  to:

                  foreach ($users as $user) {
                     if (! empty($groups)) {
                         if (! $user->isMember($groups)) continue;
                     }

                  Lines differ a bit but this hack now throws an error using ClassExtender 2.0:
                  Call to undefined method userData_mysql::isMember() in ...--Filename and linenumber--


                  Anybody with a solution?
                    Addict since 2012....
                    • 3749
                    • 24,544 Posts
                    I think with the new version, that would have to be:

                    if (! $user->User->isMember($groups)) continue;
                      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
                      • 38705
                      • 101 Posts
                      Quote from: BobRay at Aug 28, 2014, 03:49 PM
                      I think with the new version, that would have to be:

                      if (! $user->User->isMember($groups)) continue;

                      Great! That did the trick! Thank you Bob!
                        Addict since 2012....