I found this code on this forum in order to notify readers that their submission has been published:
function email_members($post_ID) {
global $post;
$email_to = get_post_meta($post->ID, 'YOUR_CUSTOMFIELD_KEY', true);
$headers = 'From: Name <name@name.com>' . \\"\r\n\\";
$subject = "Your subject here";
$message = "Your message here";
wp_mail($email_to, $subject, $message, $headers);
return $post_ID;
}
add_action('publish_post', 'email_members');
The problem is I am not sure how to use it. This is what I did:
1) I put "YOUR_CUSTOMFIELD_KEY" in the admin label of the email field.
2) I replaced Your subject here - with my subject and Your message here with my message.
It still doesn't work. Should I put the post ID somewhere? If so, where? Anything else that I should do to get it to work?