I’m working on one forum project(mostly same like drupal forums); we have public groups and private groups. Inside that groups there are public and private forums. Users can post topics and posts for those forums. Public forum topic visible to any user. Group’s private topic only visible to group members.

When I calculate total number of topics and posts for particular user, who has a permission to access those topics and posts. But this total number of topics and posts are coming wrong for normal users. It is only coming right for administrator.

How can I solve this problem?