function tehnik_filter_buddypress_activities($a, $activities)
{
    //if admin we want to know
    if (is_site_admin()) {
        return $activities;
    }
    foreach ($activities->activities as $key => $activity) {
        //new_member is the type name (component is 'profile')
        if ($activity->type == 'bbp_topic_create' || $activity->type == 'bbp_reply_create') {
            $post_id = $activity->secondary_item_id;
            if ($activity->type == 'bbp_reply_create') {
                $post_id = bbp_get_topic_forum_id($post_id);
            }
            if (!tehnik_bpp_can_user_view_post_id($post_id)) {
                unset($activities->activities[$key]);
                $activities->activity_count = $activities->activity_count - 1;
                $activities->total_activity_count = $activities->total_activity_count - 1;
                $activities->pag_num = $activities->pag_num - 1;
            }
        }
    }
    /* Renumber the array keys to account for missing items */
    $activities_new = array_values($activities->activities);
    $activities->activities = $activities_new;
    return $activities;
}
/**
 * Use the given query to determine which forums the user has access to. 
 * 
 * returns: an array of forum IDs which user has access to.
 */
function tehnik_bpp_get_permitted_post_ids($forum_query)
{
    //Check if Members plugin function exists. No need to reinvent the wheel..use what is available
    if (!function_exists('members_can_user_view_post')) {
        return array();
    }
    //Init the Array which will hold our list of allowed forums
    $allowed_posts = array();
    $post_type = $forum_query->get('post_type');
    //Loop through all the forums
    while ($forum_query->have_posts()) {
        $forum_query->the_post();
        //Get the Post ID
        $post_id = $forum_query->post->ID;
        //Get the Forum ID based on Post Type (Reply, Topic, Forum)
        $forum_id = tehnik_bpp_get_forum_id_from_post_id($post_id, $post_type);
        //Check if User has permissions to view this Post ID
        if (tehnik_bpp_can_user_view_post_id($forum_id)) {
            //User can view this post (forum) - add it to the allowed forums array
            array_push($allowed_posts, $post_id);
        }
    }
    //Return the list
    return $allowed_posts;
}