I have gotten the code to do this. However the theme I am working with does not save emails the authors input on the front end into the normal wordpress email. It instead saves it in a variable.
Original Code:
function authorEmailNotification($post_id) {
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$message = "
Hi ".$author->display_name.",
Your campaign, ".$post->post_title." is now live at ".get_permalink( $post_id ).".
";
wp_mail($author->user_email, "Your article is online", $message);
}
add_action('publish_campaigns', 'authorEmailNotification');
My Code now with the custom email variable. It is not working.
function authorEmailNotification($post_id) {
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$campaign_email = get_post_meta( $_GET['pid'], '_campaign_email', true );
$message = "
Hi ".$author->display_name.",
Your campaign, ".$post->post_title." is now live at ".get_permalink( $post_id ).".
";
wp_mail($campaign_email, "Your article is online", $message);
}
add_action('publish_campaigns', 'authorEmailNotification');
Aucun commentaire:
Enregistrer un commentaire