XF 2.2 Finding users that posted in a specific period of time


Well-known member
I decided to make a little add-on that will show me a list of users that were not active within the last 30 days, but were active within the last 60 days.
An idea is to reply to those members threads or to send PMs (depending on users options) to pull them back into activity.

That was easy.

        $time = time();
        $monthAgo = $time - 2592000;
        $twoMonthsAgo = $monthAgo - 2592000;

        $finder = $this->finder('\XF:User');
        ->setDefaultOrder('message_count', 'desc')
        ->where('last_activity', '>', $twoMonthsAgo)
        ->where('last_activity', '<', $monthAgo)
        ->limitByPage($page, $perPage);

However when I looked at those members, I realized that most of them posted last time like 10 years ago. )
So I guess I need a list of those who not just was active between $twoMonthsAgo and $monthAgo, but made a post. What would be a direction for me to move? Should I fetch posts from xf_post first, push usernames in an array, and then check those users last activity? Or there is some magic "join" way that will allow me to fetch what I need in one query?

Thanks in advance