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'm using the dob field to time a trial period.

    I need to use getCollection() (or getCollectionGraph() ) to get the username, fullname, and email address of users who are more than 14-days old. I'll also need a reference to the user object for those users.

    I could just get the modProfiles of users that meet the criteria and get the user objects with getObject(), then pull the fields directly with get(), but I suspect that a single query would be much faster.

      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
      • 33968
      • 863 Posts
      Hi Bob

      How about some variation of this?
      $time = time();  
      $datefilter = strtotime(date('Y-m-d', $time).' -2 weeks'); 
      
      $c = $modx->newQuery('modUser');
      $c->innerJoin('modUserProfile','Profile');
      $c->where(array('Profile.dob:lt' => $datefilter));
      $c->select(array('modUser.*, Profile.dob'));
      
      $users = $modx->getCollection('modUser', $c);