Jump to content

Plugin: Doesn't send email to author


habboubih

Recommended Posts

Hello,

 

I am running wordpress as my article directory. I have a plugin which sends and email to the author if the articles is rejected or approved (moved to trash or moved to publish).

 

The problem is that it doesn't send emails to authors. But it send me an email if I posted an article as an Admin if a approved or rejected it.

 

It also send emails to the admin email to notification of new articles awaiting review.

 

It doesnt sent emails to authors for approval or rejection.... thats the only problem with this plugin other than that it's fine.

 

What seems to be the problem ????

 

Here is the code:

 



<?php 

/*
Plugin Name: WP Pending Post Notifier
Plugin URI: http://www.fixwordpress.net/?p=491
Version: 1.1
Author: larry Ngaosi
Author URI: http://www.fixwordpress.net

Description: NOTE( this is plugin is no longer developed ) This plugin will email a notification when a post has been submitted for review, pending publication. Useful for moderated multi-author blogs. [<a href="http://www.fixwordpress.net/?p=491">WP Pending Post Notifier</a>]

*/

/*  Copyright YEAR  Larry Ngaosi  (email : ngaosi.larry@gmail.com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License, version 2, as 
    published by the Free Software Foundation.

    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.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
register_activation_hook( __FILE__, 'ppn_activate' );
register_deactivation_hook( __FILE__, 'ppn_deactivation' );

// Hook for adding admin menus
add_action('admin_menu', 'sn_add_option_page');

// action function for above hook
function sn_add_option_page() {
    // Add a new submenu under options:
    add_options_page('Pending Post Notifications', 'Pending Notifications', 'edit_themes', 'status_notifier', 'sn_options_page');
}

function sn_options_page() {
if(isset($_POST['save'])) {
      update_option('notificationemails',$_POST['notificationemails']);
      update_option('approvednotification',$_POST['approvednotification']);
      update_option('declinednotification',$_POST['declinednotification']);
  echo "<div id='message' class='updated fade'><p>Notification settings saved.</p></div>";
    }
    ?>
<div class="wrap"><h2>Pending Post Notifications</h2>
<form name="site" action="" method="post" id="notifier">
<table class="form-table">
	<tbody>
	<tr valign="top">
		<th scope="row"><label for="notificationemails">Notification Reciever</label></th>
		<td><input type="text" size="50" name="notificationemails" tabindex="1" id="notificationemails" value="<?php echo esc_attr(get_option('notificationemails')); ?>"><br>
Enter email addresses which should be notified of posts pending review</td>
	</tr>

	<tr valign="top">
		<th scope="row">Pending Review Notifications</th>
		<td>
			<fieldset>
				<legend class="hidden">Pending Review Notifications</legend>

				<label for="approvednotification"><input type="checkbox" tabindex="2" id="approvednotification" name="approvednotification" value="yes" <?php if(get_option('approvednotification')=='yes') echo 'checked="checked"'; ?> /> Notify contributor when their post is approved</label><br>
				<label for="declinednotification"><input type="checkbox" tabindex="3" id="declinednotification" name="declinednotification" value="yes" <?php if(get_option('declinednotification')=='yes') echo 'checked="checked"'; ?> /> Notify contributor when their post is declined (sent back to drafts)</label><br>

			</fieldset>
		</td>
	</tr>




</tbody></table>


<p class="submit">
<input name="save" type="submit" id="savenotifier" tabindex="6" style="font-weight: bold;" value="Save Settings" />
</p>

</form>
	</div>
<?php
}



add_filter('transition_post_status', 'notify_status',10,3);
function notify_status($new_status, $old_status, $post) {
    global $current_user;
$contributor = get_userdata($post->post_author);
    if ($old_status != 'pending' && $new_status == 'pending') {
      $emails=get_option('notificationemails');
      if(strlen($emails)) {
        $subject='['.get_option('blogname').'] "'.$post->ID.'" pending review';
        $message="A new post by {$contributor->display_name} is pending review.\n\n";
        $message.="Author   : {$contributor->user_login} {$contributor->user_email} (IP: {$_SERVER['REMOTE_ADDR']})\n";
        $message.="Title    : {$post->post_title}\n";
	$category = get_the_category($post->ID);
	if(isset($category[0])) 
		$message.="Category : {$category[0]->name}\n";;
        $message.="Review it: ".get_option('siteurl')."/wp-admin/post.php?action=edit&post={$post->ID}\n";


$queried_post = get_post($post->ID);




        $message.="Title: ".$queried_post->post_title."\n";
        $message.="Content: \n".$queried_post->post_content."\n\n\n";
	$headers = 'From: My name here <no-reply@xxxxxxxxx.com>' . "\r\n";

        wp_mail('admin@xxxxxxxxxx.com', $subject, $message, $headers);
      }
} elseif ($old_status == 'pending' && $new_status == 'publish' && $current_user->ID == $contributor->ID) {
      if(get_option('approvednotification')=='yes') {
  $contributor = get_userdata($post->post_author);
        $subject='['.get_option('blogname').'] "'.$post->post_title.'" approved';
        $message="{$contributor->display_name},\n\nYour post has been approved and published at:\n ".get_permalink($post->ID)." .";
	$message.="\n\nThank you for choosing xxxxxx.com";
        $message.="\n\nPlease do not reply to this email. Use the contact us form instead.";
	$message.="\n\nSincerely,\nThe xxxxxxxxxx Team.\nhttp://www.xxxxxxxx.com";

	$headers = 'From: xxxxxxxxx <no-reply@xxxxxxxxx.com>' . "\r\n";
        wp_mail( $contributor->user_email, $subject, $message, $headers);
      }
} elseif ($old_status == 'pending' && $new_status == 'trash' && $current_user->ID == $contributor->ID) {
      if(get_option('declinednotification')=='yes') {
  $contributor = get_userdata($post->post_author);
        $subject='['.get_option('blogname').'] "'.$post->post_title.'" declined';
        $message="{$contributor->display_name},\n\nWe are sorry to inform you that your article:\n(".$post->post_title.")\nat xxxxxxxxx.com has been declined.";
        
	$message.="\n\nIt is possible because of one or more of the following reasons:\n\n";
	$message.="1. You are posting duplicate contents.\n";
	$message.="2. You are using long titles.\n";
	$message.="3. Article is less than 450 words.\n";
	$message.="4. Title is not relevant to contents.\n";
	$message.="\n\n Read the following page for Terms of Use:\n http://www.xxxxxxxxx.com/terms-of-use";

        $message.="\n\nPlease do not reply to this email. Use the contact us form instead.";

	$message.="\n\nSincerely,\nThe xxxxxxx Team.\nhttp://www.xxxxxxxxx.com";

	$headers = 'From: xxxxxxxxxx <no-reply@xxxxxxxxx.com>' . "\r\n";
        wp_mail( $contributor->user_email, $subject, $message, $headers);
      }
} 
}

function ppn_activate() {
  add_option('notificationemails',get_option('admin_email'));
    add_option('approvednotification','yes');
    add_option('declinednotification','yes');
}
function ppn_deactivation() {
delete_option('notificationemails');
delete_option('approvednotification');
delete_option('declinednotification');
}


?>

Link to comment
Share on other sites

  • 2 weeks later...

this looks legit. what's the name of the plugin? are there any errors coming from your mail server? or logs?

 

As shown, the plugin name is: WP Pending Post Notifier

 

I am not receiving any errors on the mail.

my bad. i'm testing this on my server to see if i can help you fix this.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.