PluginProbe
Private groups / 1.6
Private groups v1.6
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 / replies.php

replies.php in Private groups 1.6, at includes/replies.php

58 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 add_filter ('bbp_get_user_replies_created', 'pg_get_user_replies_created') ;
4
5 function pg_get_user_replies_created( $user_id = 0 ) {
6
7 // Validate user
8 $user_id2 = bbp_get_user_id( $user_id );
9 if ( empty( $user_id ) )
10 return false;
11
12 global $wpdb;
13
14 $post_ids=$wpdb->get_col("select ID from $wpdb->posts where post_type = 'reply'") ;
15 //check this list against those the user is allowed to see, and create a list of valid ones for the wp_query in bbp_has_topics
16 $allowed_posts = check_private_groups_reply_ids($post_ids) ;
17
18 // The default reply query with allowed topic and reply ids array added
19
20 // Try to get the topics
21 $query = bbp_has_replies( array(
22 'post_type' => bbp_get_reply_post_type(),
23 'order' => 'DESC',
24 'author' => $user_id2,
25 'post__in' => $allowed_posts
26 ) );
27
28 return apply_filters( 'pg_get_user_replies_created', $query, $user_id );
29 }
30
31 //the function to check the above !
32 function check_private_groups_reply_ids($post_ids) {
33
34 //Init the Array which will hold our list of allowed posts
35 $allowed_posts = array();
36
37
38 //Loop through all the posts
39 foreach ( $post_ids as $post_id ) {
40 //Get the Forum ID based on Post Type Topic
41 $forum_id = private_groups_get_forum_id_from_post_id($post_id, 'reply');
42 //Check if User has permissions to view this Post ID
43 //by calling the function that checks if the user can view this forum, and hence this post
44 if (private_groups_can_user_view_post_id($forum_id)) {
45
46 //User can view this post - add it to the allowed array
47 array_push($allowed_posts, $post_id);
48 }
49 }
50
51 //Return the list
52 return $allowed_posts;
53 }
54
55
56
57
58