Custom Email on Post
-
I need a plugin (or some code to put in my functions file) developed that automatically sends a customized email when a post is published. The email address of the recipient is stored in a custom field associated with the post.
I found this chunk of code which is a good start:
function authorNotification($post_id) {
$post = get_post($post_id);
$author = get_userdata($post->post_author);$message = “
Hi “.$author->display_name.”,
Your post, “.$post->post_title.” has just been published at “.get_permalink( $post_id ).”. Well done!
“;
wp_mail($author->user_email, “Your article is online”, $message);
}
add_action(‘publish_post’, ‘authorNotification’);I also need to make sure it does the following.
* Send on ‘Publish’ only. This is important because we create Drafts and Schedule posts in advance. Must only go out on final Publish.
* Check to see if the custom field [email] has been filled out. If not, don’t send.
* Subject will contain Title of Post as well as some template stuff e.g. Your Story “Story Title Here” Is Live Today
* Send a html email to the address found in the custom field.
* Personalize the email with the name found in the [author] custom field.
* Ability to customize the following:
* From name
* From email address
* Email SubjectAny help to get me further along is much appreciated. I can also donate a little bit to help out.
The topic ‘Custom Email on Post’ is closed to new replies.