| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | - | |
| 2 | +//this is only used (as far as I can see) by the 'replies created' part of the user profile | |
| 3 | + | |
| 3 | 4 | add_filter ('bbp_get_user_replies_created', 'pg_get_user_replies_created') ; |
| 4 | 5 | |
| 5 | 6 | function pg_get_user_replies_created( $user_id = 0 ) { |
| 6 | 7 | |
| @@ -5,18 +6,30 @@ | ||
| 5 | 6 | function pg_get_user_replies_created( $user_id = 0 ) { |
| 6 | 7 | |
| 7 | 8 | // Validate user |
| 8 | 9 | $user_id2 = bbp_get_user_id( $user_id ); |
| 10 | + $current_user= wp_get_current_user()->ID; | |
| 9 | 11 | if ( empty( $user_id ) ) |
| 10 | 12 | return false; |
| 11 | - | |
| 13 | + | |
| 14 | + if ( bbp_is_user_keymaster()) $limit='n' ; | |
| 15 | + | |
| 16 | + if (user_can( $current_user, 'moderate' ) ) { | |
| 17 | + $check=get_user_meta( $current_user, 'private_group',true); | |
| 18 | + if ($check=='') $limit='n' ; | |
| 19 | + } | |
| 20 | + if ($limit != 'n') { | |
| 12 | 21 | global $wpdb; |
| 22 | + $reply=bbp_get_reply_post_type() ; | |
| 23 | + $post_ids=$wpdb->get_col("select ID from $wpdb->posts where post_type = '$reply'") ; | |
| 24 | + //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 | |
| 25 | + $allowed_posts = check_private_groups_reply_ids($post_ids) ; | |
| 13 | 26 | |
| 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 | |
| 27 | + } | |
| 28 | + | |
| 29 | + // The default reply query with allowed topic and reply ids array added | |
| 30 | + | |
| 31 | + | |
| 19 | 32 | |
| 20 | 33 | // Try to get the topics |
| 21 | 34 | $query = bbp_has_replies( array( |
| 22 | 35 | 'post_type' => bbp_get_reply_post_type(), |
| @@ -37,9 +50,10 @@ | ||
| 37 | 50 | |
| 38 | 51 | //Loop through all the posts |
| 39 | 52 | foreach ( $post_ids as $post_id ) { |
| 40 | 53 | //Get the Forum ID based on Post Type Topic |
| 41 | - $forum_id = private_groups_get_forum_id_from_post_id($post_id, 'reply'); | |
| 54 | + $reply=bbp_get_reply_post_type() ; | |
| 55 | + $forum_id = private_groups_get_forum_id_from_post_id($post_id, $reply); | |
| 42 | 56 | //Check if User has permissions to view this Post ID |
| 43 | 57 | //by calling the function that checks if the user can view this forum, and hence this post |
| 44 | 58 | if (private_groups_can_user_view_post_id($forum_id)) { |
| 45 | 59 | |