[wp-hackers] Category-Specific Email Notification Plugin
Danny Dawson
quasistoic at gmail.com
Tue Oct 5 19:55:09 UTC 2004
Sorry, I'm still having trouble trying to figure out where exactly to
insert that statement. I tried inserting it before SELECT TITLE FROM
DB and I've tried inserting it before
if (isset($_POST['publish'])) $post_status = 'publish';
with no luck. I've attached most of the relevant code (from the
beginning of the plugin) below.
//********************************************************//
// CREATE VARIABLES
//********************************************************//
if(!isset($wpdb->posts)) {
$wpdb->posts = $table_prefix . 'posts';
$wpdb->postmeta = $table_prefix . 'postmeta';
$wpdb->users = $table_prefix . 'users';
}
if(!isset($wpdb->email_list)) {
$wpdb->email_list = $table_prefix . 'email_list';
}
// add_action(hook, action, priority)
// [priority 0-10 with 0 being the highest priority]
add_action('publish_post', 'send_notification', 5);
function send_notification($post_ID) {
//********************************************************//
// CONFIG SECTION
//********************************************************//
$from_email = 'intranet at fontshop.com';
$nice_urls = 'no'; // yes or no
$show_content = 'yes'; // yes or no - send the entire post in email
$html_email = 'no'; // yes for HTML, no for Text
//********************************************************//
// OTHER SETTINGS
//********************************************************//
# Site Information
$site_name = get_settings('blogname');
$site_url = get_settings('siteurl');
$blog_url = get_settings('home');
# Set Global
global $wpdb;
//********************************************************//
// GRAB POST STATUS
//********************************************************//
$prev_status = $_POST['prev_status'];
$post_status = $_POST['post_status'];
if (isset($_POST['publish'])) $post_status = 'publish';
//********************************************************//
// are we going from draft/private to published?
//********************************************************//
if ($prev_status != 'publish' && $post_status == 'publish') {
//********************************************************//
// SELECT TITLE FROM DB
//********************************************************//
$query = "SELECT post_title, post_content FROM $wpdb->posts WHERE
ID = '$post_ID'";
$row = $wpdb->get_row($query);
$post_title = stripslashes($row->post_title);
$post_title =
str_replace(array("“","â€?","’","â€"","â€"","…"),
array('"','"','´','–','—','...'), $post_title);
$post_title = utf8_decode($post_title);
$post_content = stripslashes($row->post_content);
$post_content =
str_replace(array("“","â€?","’","â€"","â€"","…"," "),
array('"','"','´','–','—','...',' '), $post_content);
$post_content = utf8_decode($post_content);
if ($html_email != 'yes'){
$post_content =
str_replace(array("<ul>","</ul>","<ol>","</ol>","<li>","</li>"),
array('','','','','* ',''), $post_content);
$post_content = strip_tags($post_content);
}
On Tue, 5 Oct 2004 14:59:41 -0400, Tor Bjornrud <bjornrud at msu.edu> wrote:
> > Brian has authored an Email Notification Plugin which notifies a list
> > of users when a new blog post is published:
> > http://www.briangroce.com/software/wp-email-notification.html
> >
> > How difficult would it be to modify this plugin to be
> > category-specific?
>
> Not very hard at all, probably around 4 lines of code or so. You need
> to find out the category number, and in at the place where the plugin
> actually does its stuff add something like (pseudo-code warning):
>
> if(in_category(33)){
>
> and remember to close the codeblock at the end of the meat of the code.
>
> ~Tor
>
>
>
>
> _______________________________________________
> hackers mailing list
> hackers at wordpress.org
> http://wordpress.org/mailman/listinfo/hackers_wordpress.org
>
--
Danny Dawson
http://quasistoic.org/ts/
More information about the hackers
mailing list