All Good Things Must Come To An End

As you all know, I have been doing WordPress plugins and supporting it for the past 6 years. These 6 years of my life, I have been through my polytechnic education, my national service as well as my university education.

I just graduated from university in December 2009 and have been looking for full-time jobs. I am offered a full-time job and will be starting work on 1st February 2010.

I regret to say that I am NOT ABLE to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

However, I WILL still update my plugins whenever I can and you still can report bugs to me via email and I will try to fix it.

Author Topic: Successful emails per post?  (Read 1455 times)

0 Members and 1 Guest are viewing this topic.

Offline jschodde

  • Newbie
  • *
  • Posts: 21
    • View Profile
Successful emails per post?
« on: 31 July 2009, 16:46 »
I need a way to indicate how many times a post was emailed. I found the get_emails_success() function and I can see the sql statement. I think I would create a new function based on this one, and modify the sql statement to search for the current post. Can anyone offer me a little help on how I would set up the sql statement?  ::)

### Function: Get EMail Total Sent Success
if(!function_exists('get_emails_success')) {
   function get_emails_success($echo = true) {
      global $wpdb;
      $totalemails_success = $wpdb->get_var("SELECT COUNT(email_id) FROM $wpdb->email WHERE email_status = '".__('Success', 'wp-email')."'");
      if($echo) {
         echo number_format_i18n($totalemails_success);
      } else {
         return number_format_i18n($totalemails_success);
      }
   }
}

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Successful emails per post?
« Reply #1 on: 01 August 2009, 04:40 »
Code: [Select]
SELECT COUNT(email_id) FROM $wpdb->email WHERE email_status = '".__('Success', 'wp-email')."' AND email_postid = 1"Where 1 is your post ID[/code]

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline jschodde

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Successful emails per post?
« Reply #2 on: 01 August 2009, 15:46 »
Code: [Select]
SELECT COUNT(email_id) FROM $wpdb->email WHERE email_status = '".__('Success', 'wp-email')."' AND email_postid = 1"Where 1 is your post ID[/code]

Thanks Lester, I got it working. Here is the new function in case someone needs it. Let me know if you see anything wrong with it please:

Code: [Select]
### Function: Get EMail Total Sent Success by Post
if(!function_exists('get_emails_success_by_post')) {
function get_emails_success_by_post($echo = true) {
global $wpdb, $post;
$totalemails_success = $wpdb->get_var("SELECT COUNT(email_id) FROM $wpdb->email WHERE email_status = '".__('Success', 'wp-email')."' AND email_postid=$post->ID");
if($echo) {
echo number_format_i18n($totalemails_success);
} else {
return number_format_i18n($totalemails_success);
}
}
}

Usage:

Code: [Select]
<?php if (function_exists('get_emails_success_by_post')) { get_emails_success_by_post(); } ?><?php _e(' emails','cp'); ?>

This will display: "nnn emails", where nnn is the count.

Thanks,
Jeff

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Successful emails per post?
« Reply #3 on: 01 August 2009, 16:11 »
Cool thanks =)

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.