XF 1.5 SQL Query Help

Ark Royal

Active member
Can anyone help me and provide me with an SQL Query that will allow me to see when members of a particular user group last made a post?

Many Thanks


Well-known member
select username, from_unixtime(last_activity) from xf_user where find_in_set('xx',secondary_group_ids) <> 0 order by last_activity desc;

..... replace xx with the usergroup id you want to check against
If the users in question have the desired usergroup as a secondary_group_id... this example is selecting members in user group 9 and showing their last post time:

SELECT user.username, MAX(post.post_date) AS last_post_date FROM xf_user AS user
LEFT JOIN xf_post AS post ON(post.user_id = user.user_id)
WHERE FIND_IN_SET(9, user.secondary_group_ids) GROUP BY post.user_id ORDER BY last_post_date DESC;
This is fairly basic. It's not checking to see if that last post is soft-deleted or moderated, for example, and the date is output as a UNIX time format value.