$result ) { $postcheck= $result['ID'] ; //look up post type $pg_post_type = get_post_type( $postcheck ) ; //test to see if post if topic, reply or forum if ( ($pg_post_type == bbp_get_forum_post_type() ) || ($pg_post_type == bbp_get_topic_post_type() ) || ($pg_post_type == bbp_get_reply_post_type() ) ) { //Get the Forum ID based on Post Type (Reply, Topic, Forum) $pg_forum_id = private_groups_get_forum_id_from_post_id($postcheck, $pg_post_type); //test to see if not allowed this forum if (private_groups_can_user_view_post_id($pg_forum_id) == false || topic_permissions_check ($postcheck) == false) { //and if so unset the result unset ($results[$key]) ; } } } return apply_filters( 'rpg_link_query', $results, $query ); }