Advertisement
shansta

Untitled

Jan 5th, 2012
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. $current_user_profile = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
  2. $lid = $current_user_profile->ID;
  3. $user_meta_tw_id = $current_user_profile->user_login;
  4. $dl_tw_url = "http://twitter.com/$user_meta_tw_id";
  5. $some_email = $current_user_profile->user_email; //Gets Authors email
  6.  
  7.  
  8. $querystr = "
  9. SELECT a.comment_ID, a.comment_post_ID, a.comment_content, a.comment_date_gmt, a.comment_author_url, b.post_title, b.ID
  10. FROM $wpdb->comments a, $wpdb->posts b
  11. WHERE a.comment_post_ID = b.ID
  12. AND (a.comment_author_email = '$some_email'
  13.  
  14. OR a.comment_author_url = '$dl_tw_url')
  15. AND a.comment_approved = 1
  16. GROUP BY a.comment_ID
  17. ORDER BY a.comment_ID DESC
  18. ";
  19.  
  20. $comments_array = $wpdb->get_results($querystr, OBJECT);
  21. if ($comments_array):
  22. $cpp = 10; // Comments per page
  23. $wp_query->found_posts = count($comments_array);
  24. //echo $wp_query->found_posts;
  25. $wp_query->max_num_pages = ceil($wp_query->found_posts / $cpp);
  26. $on_page = intval(get_query_var('paged'));
  27. if($on_page == 0){ $on_page = 1; }
  28. $offset = ($on_page-1) * $cpp;
  29.  
  30. $wp_query->request = "
  31. SELECT a.comment_ID, a.comment_post_ID, a.comment_content, a.comment_date_gmt, a.comment_author_url, b.post_title, b.ID
  32. FROM $wpdb->comments a, $wpdb->posts b
  33. WHERE a.comment_post_ID = b.ID
  34. AND (a.comment_author_email = '$some_email'
  35. OR a.comment_author_url = '$dl_tw_url')
  36. AND a.comment_approved = 1
  37. GROUP BY a.comment_ID
  38. ORDER BY a.comment_ID DESC
  39. LIMIT $cpp
  40. OFFSET $offset
  41. ";
  42. $pagecomments = $wpdb->get_results($wp_query->request, OBJECT);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement