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; }
function pg_get_author_link() { $user_id2 = wp_get_current_user()->ID; // Parse arguments against default values $r = bbp_parse_args($args, array('post_id' => $post_id, 'link_title' => '', 'type' => 'both', 'size' => 14), 'pg_get_author_link'); //confirmed topic if (bbp_is_topic($post_id)) { $topic = bbp_get_topic_post_type(); $forum_id_check = private_groups_get_forum_id_from_post_id($post_id, $topic); //now we can check if the user can view this if (!private_groups_can_user_view_post($user_id2, $forum_id_check)) { return; } return bbp_get_topic_author_link($r); // Confirmed reply } elseif (bbp_is_reply($post_id)) { $reply = bbp_get_reply_post_type(); $forum_id_check = private_groups_get_forum_id_from_post_id($post_id, $reply); //now we can check if the user can view this if (!private_groups_can_user_view_post($user_id2, $forum_id_check)) { return; } return bbp_get_reply_author_link($r); } // Neither a reply nor a topic, so could be a revision //if it isn't a topic or reply, not sure so better to just not display the author in this case //could be revised to look up the post_parent of this post and then churn that round the code above if required return ; return; }