WordPress.org

Ready to get started?Download WordPress

Forums

Send "Pending Review" Email to Specific Email Address (1 post)

  1. inhouse
    Member
    Posted 1 year ago #

    Hi, I'm trying to get emails sent to a single specific email address. I've tried Edit Flow plugin and a couple others like WP Status Notifier. So I found this old plugin I'm trying to modify. It sends an email to the site admin when a new post is saved as Pending Review. Perfect except I need it to do to a specific user, NOT the admin. Is there any way to get a specific user ID email? Or even just write in a specific email address? Or I could send it to all "Editors" email addresses. Whatever works really.

    I believe the line I need to edit is:

    $recipient = get_bloginfo('admin_email');

    Full plugin code:

    function dddn_process($id) {
    
    	global $wpdb;
    
    	$tp = $wpdb->prefix;
    
    	$result = $wpdb->get_row("
    		SELECT post_status, post_title, user_login, user_nicename, display_name
    		FROM {$tp}posts, {$tp}users
    		WHERE {$tp}posts.post_author = {$tp}users.ID
    		AND {$tp}posts.ID = '$id'
    	");
    
    	if ($result->post_status == "pending") {
    
    		$message = "";
    		$message .= "A draft was saved on '" . get_bloginfo('name') . "'\n\n";
    		$message .= "Title: " . $result->post_title . "\n\n";
    
    			// *** Choose one of the following options to show the author's name
    		$message .= "Author: " . $result->display_name . "\n\n";
    		// $message .= "Author: " . $result->user_nicename . "\n\n";
    		// $message .= "Author: " . $result->user_login . "\n\n";
    		$message .= "Link: " . get_permalink($id);
    		$subject = "Draft Updated on '" . get_bloginfo('name') . "'";
    		$recipient = get_bloginfo('admin_email');
    		mail($recipient, $subject, $message);
    	}
    }
    add_action('save_post', 'dddn_process');

Topic Closed

This topic has been closed to new replies.

About this Topic