Skip to content

Instantly share code, notes, and snippets.

@benmay
Created July 15, 2013 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benmay/5997456 to your computer and use it in GitHub Desktop.
Save benmay/5997456 to your computer and use it in GitHub Desktop.
$email = $this->email;
global $wpdb;
- if($fix)
- {$fix = "comment_post_ID = $fix AND ";}
+ if($fix) {
+ $fix_comments = "comment_post_ID = $fix AND ";
+ $fix_postmeta = "post_ID = $fix AND ";
+ }
$email = $wpdb->escape(strtolower($email));
- $subscriptions = $wpdb->get_results("SELECT comment_post_ID FROM $wpdb->comments WHERE $fix LCASE(comment_author_email) = '$email' AND comment_subscribe='Y' AND comment_approved = '1' GROUP BY comment_post_ID");
+ $subscriptions = $wpdb->get_results("SELECT comment_post_ID FROM $wpdb->comments WHERE $fix_comments LCASE(comment_author_email) = '$email' AND comment_subscribe='Y' AND comment_approved = '1' GROUP BY comment_post_ID");
foreach ( (array) $subscriptions as $subscription )
$this->email_subscriptions[] = $subscription->comment_post_ID;
- $subscriptions = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE $fix meta_key = '_sg_subscribe-to-comments' AND LCASE(meta_value) = '$email' GROUP BY post_id");
+ $subscriptions = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE $fix_postmeta meta_key = '_sg_subscribe-to-comments' AND LCASE(meta_value) = '$email' GROUP BY post_id");
foreach ( (array) $subscriptions as $subscription)
$this->email_subscriptions[] = $subscription->post_id;
if ( is_array($this->email_subscriptions) ) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment