Email Pending Posts – WordPress Plugin

Email pending posts is a WordPress plugin that I wrote, which will email a notification to the admin email of the blog, when a post’s status has been changed from DRAFT to PENDING.  This may be a useful feature for moderated multi-author WordPress blogs, wherein contributors may write and SUBMIT FOR REVIEW, for a user with publication privileges to publish the post.

Download

emailpendingposts_ver0-2.php.zip 1.5 KB [Stable] … Tested with WordPress 2.8.4

Installation

  1. Unzip “emailpendingposts_ver0-2.php.zip” and upload “emailpendingposts_ver0-2.php” to the “…/wp-content/plugins/” directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress

No further action is necessary and there are no associated settings.  It will send an email notification when a post has been submitted for review and its status is PENDING; similar to the notification sent when a comment is awaiting moderation.

License

This plugin is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License, version 3 (GPLv3). See http://www.gnu.org/licenses/ for more information.

Use and Enjoy

  • If you use it, a link to your blog in the comments would be good
  • If you wish to develop on this plugin, please do and let me know the link so that I can publish it here.

Plugin Code


/*
Plugin Name: Email Pending Posts
Plugin URI: http://www.fayid.com/20090822/email-pending-posts-wordpress-plugin/
Version: 0.2
Author: Fayid
Description: This plugin will email a notification when a post has been submitted for review, pending publication. Useful for moderated multi-author blogs.
*/
?>

/*
LICENCE: GNU GPLv3

Emailpendingposts.php - A WordPress plugin: Emails notification of posts submitted for review.
Copyright (C) 2009 Fayid

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 3 (GPLv3).

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

See http://www.gnu.org/licenses/ for more information.
*/
?>

function fayid_emailpendingposts($post_ID) {

$blogtitle = get_bloginfo('name');
$installedurl = get_bloginfo('wpurl');
$editposturl = $installedurl."/wp-admin/edit.php";

$pendingpost = get_post($post_ID);
$posttitle = $pendingpost->post_title;
$poststatus = $pendingpost->post_status;
$postcontent = $pendingpost->post_content;

$postauthorid = $pendingpost->post_author;
$authorinfo = get_userdata($postauthorid);
$authorname = $authorinfo->display_name;
$authoremail = $authorinfo->user_email;
$authorurl = $authorinfo->user_url;

$receipients = get_option('admin_email');
$subject = "[".$blogtitle."] Please publish: \"".$posttitle."\" by ".$authorname;
$message = "A new post is ".$poststatus." for you to approve and publish.\n";
$message .= $editposturl."\n\n";
$message .= "Author: ".$authorname."\n";
$message .= "Email: ".$authoremail."\n";
$message .= "URL: ".$authorurl."\n\n";
$message .= "TITLE: ".$posttitle."\n\n";
$message .= "CONTENTS:\n\n".$postcontent;
$message_stripped = strip_tags($message);

wp_mail($receipients, $subject, $message_stripped);
}

add_action('draft_to_pending', 'fayid_emailpendingposts');

?>

To-do (need-based and time permitting)

  • Implement a Settings Page to enable users to specify notification email addresses