function check_private_groups_topic_ids($post_ids) { //Init the Array which will hold our list of allowed posts $allowed_posts = array(); //Loop through all the posts foreach ($post_ids as $post_id) { //Get the Forum ID based on Post Type Topic $topic = bbp_get_topic_post_type(); $forum_id = private_groups_get_forum_id_from_post_id($post_id, $topic); //Check if User has permissions to view this Post ID //by calling the function that checks if the user can view this forum, and hence this post if (private_groups_can_user_view_post_id($forum_id)) { //User can view this post - add it to the allowed array array_push($allowed_posts, $post_id); } } //Return the list return $allowed_posts; }
/** * Use the given query to determine which forums the user has access to. * * returns: an array of post IDs which user has access to. */ function private_groups_get_permitted_post_ids($post_query) { //Init the Array which will hold our list of allowed posts $allowed_posts = array(); //Loop through all the posts while ($post_query->have_posts()) { $post_query->the_post(); //Get the Post ID and post type $post_id = $post_query->post->ID; $post_type = $post_query->post->post_type; //Get the Forum ID based on Post Type (Reply, Topic, Forum) $forum_id = private_groups_get_forum_id_from_post_id($post_id, $post_type); //Check if User has permissions to view this Post ID //by calling the function that checks if the user can view this forum, and hence this post if (private_groups_can_user_view_post_id($forum_id)) { //User can view this post - add it to the allowed array array_push($allowed_posts, $post_id); } } //Return the list return $allowed_posts; }