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

    My team is developing an Extra for MODx 2.2.7 (Advanced Installation) and have extended the modUser class. We have tested all processors so far and they work fine.

    The only problem is with the GetListProcessor. It keeps returning modUsers, too. Our implementation looks like this:
    class customUserGetListProcessor extends modUserGetListProcessor {
      
      public $classKey = 'customUser';
    
      ...
    }
    


    Could anyone, please, tell us if there is anything else required in order for that processor to return only customUsers?

    We have tried one alternative solution, but it, then, returns no users at all.

    Buggy Alternative
    public function prepareQueryBeforeCount(xPDOQuery $c) {
      $c->where(array('modUser.class_key' => 'customUser'));
    
      return parent::prepareQueryBeforeCount($c);
    }
    

    This question has been answered by multiple community members. See the first response.

    [ed. note: leffyrant last edited this post 13 years, 5 months ago.]
    • discuss.answer
      • 3749
      • 24,544 Posts
      We'd need to see more of your code, but have you tried this:

      
      $c = $modx->newQuery('modUser');
      $c->where(array('class_key' => 'customUser'));
      $users = $modx->getCollection('modUser', $c);
      
      
        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
      • discuss.answer
        • 38371
        • 42 Posts
        Thank you for your answer BobRay.

        The problem can indeed be solved with the 'class_key' criterion. We were using this:
        'modUser.class_key'

        while, in fact, we should be using this:
        'class_key' or 'customUser.class_key'

        I include the code of the whole class below.
        class customUserGetListProcessor extends modUserGetListProcessor {
        
            public $classKey = 'customUser';
        
            public function prepareQueryBeforeCount(xPDOQuery $c) {
                $c->where(array('class_key' => $this->classKey));
        
                return parent::prepareQueryBeforeCount($c);
            }
        }