Scandal
Well-known member
Hello all!
I want to use xF2 Finder to detect accounts with member age (in years), between X and Y.
Let's say that we want to detect the accounts that have age between 18 and 21 years old.
How exact do I have to edit the finder?
I used XF:UserProfile cause its table has the following columns:
->getAge()
Currently I'm doing this:
... but I want deprecate that code and starting initially to select the members between 18 and 21 years (= where 18 and 21, I will be able to put any value).
So I don't want to fetch more users and checking via php to limit the results like the above code.
Any way to select them directly via the $finder?
I want to use xF2 Finder to detect accounts with member age (in years), between X and Y.
Let's say that we want to detect the accounts that have age between 18 and 21 years old.
How exact do I have to edit the finder?
PHP:
$finder = \XF::finder('XF:UserProfile')->with('User');
- dob_day
- dob_month
- dob_year
->getAge()
Currently I'm doing this:
PHP:
foreach ($users AS $u)
{
if ($u->getAge(true) >= 18 && $u->getAge(true) <= 21)
{
$output[] = $u->User;
}
}
... but I want deprecate that code and starting initially to select the members between 18 and 21 years (= where 18 and 21, I will be able to put any value).
So I don't want to fetch more users and checking via php to limit the results like the above code.
Any way to select them directly via the $finder?