function get_comments_for_user($user_id = null)
 {
     global $bp, $wpdb;
     if (!$bp->blogs) {
         bp_blogs_setup_globals();
     }
     if (!$user_id) {
         $user_id = $bp->displayed_user->id;
     }
     // Show the logged in user their comments on hidden blogs, but not to anyone else.
     if (!bp_is_home()) {
         $comment_ids = $wpdb->get_results($wpdb->prepare("SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id));
         $total_comment_count = $wpdb->get_var($wpdb->prepare("SELECT count(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id));
     } else {
         $comment_ids = $wpdb->get_results($wpdb->prepare("SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id));
         $total_comment_count = $wpdb->get_var($wpdb->prepare("SELECT count(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id));
     }
     for ($i = 0; $i < count($comment_ids); $i++) {
         $comments[$i] = BP_Blogs_Comment::fetch_comment_content($comment_ids[$i]);
     }
     return array('comments' => $comments, 'count' => $total_comment_count);
 }
Example #2
0
function bp_blogs_remove_data($user_id)
{
    /* If this is regular blog, delete all data for that blog. */
    BP_Blogs_Blog::delete_blogs_for_user($user_id);
    BP_Blogs_Post::delete_posts_for_user($user_id);
    BP_Blogs_Comment::delete_comments_for_user($user_id);
    do_action('bp_blogs_remove_data', $user_id);
}