PluginProbe
Private groups / trunk
Private groups vtrunk
trunk 1.5 1.6 1.7 1.8 1.8.1 1.9.1 1.9.2 2.0 2.0.1 2.2 2.3 2.4 2.5 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 All 116 releases
bbp-private-groups / includes / link_query.php

link_query.php in Private groups trunk, at includes/link_query.php

35 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 //When posting a new topic, or replying, users can click the link button. This brings up a list of recent posts, pages, topics and replies using wp_link_query
4 //This filter takes the 'results' array from wp-link-query and filters it to exclude topics, replies or forums that the user is not allowed to see
5
6 add_filter( 'wp_link_query', 'rpg_link_query', 10, 2 );
7
8 Function rpg_link_query ($results, $query) {
9
10 //bring in the $results array that wp_link_query creates and sort through
11 foreach ( $results as $key => $result ) {
12 $postcheck= $result['ID'] ;
13 //look up post type
14 $pg_post_type = get_post_type( $postcheck ) ;
15 //test to see if post if topic, reply or forum
16 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() ) ) {
17 //Get the Forum ID based on Post Type (Reply, Topic, Forum)
18 $pg_forum_id = private_groups_get_forum_id_from_post_id($postcheck, $pg_post_type);
19
20 //test to see if not allowed this forum
21 if (private_groups_can_user_view_post_id($pg_forum_id) == false || topic_permissions_check ($postcheck) == false) {
22 //and if so unset the result
23 unset ($results[$key]) ;
24 }
25
26 }
27
28 }
29 return apply_filters( 'rpg_link_query', $results, $query );
30 }
31
32
33
34
35