-
- 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.
-
- 102 Posts
Hi,
this should do it:
$criteria=$modx->newQuery('modUser');
$criteria->innerJoin('modUserProfile','Profile');
$criteria->where(array(
'Profile.city' => 'Zagreb',
));
$users=$modx->getCollectionGraph('modUser', '{ "modUserProfile":{} }',$criteria);
foreach ($users as $user) {
echo $user->username;
$profile=$user->getOne('Profile');
echo $profile->city;
}
P.S. I used city for criteria from modUserProfile, but you got idea.
Feel free to ask if you have additional questions.
Antonio Zdilar
linearvector.com
-
- 24,544 Posts
Thanks. I ended up using getIterator() because I needed to filter by user group as well.
Don't know my post got double-posted.
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODx info for everyone:
http://bobsguides.com/modx.html