'How can I send email to an email stored in a custom post type?
//Sending Email
add_action( 'transition_post_status', 'notify_author_on_publish', 10, 3 );
function notify_author_on_publish( $new_status, $old_status, $post ) {
if ( 'publish' !== $new_status ||
$new_status === $old_status ||
'directories' !== get_post_type( $post ) ) {
return;
}
// Get the post author data.
if ( ! $user = get_userdata( $post->post_author ) ) {
return;
}
// Compose the email message.
$body = "
Hi ".$author->display_name.",
Your listing, \"".$post->post_title."\" has just been published.
Reserver a Booth! https://example.com/
Thank You, Admin";
// Now send to the post author.
wp_mail( $user->user_email, 'Your listing is published!', $body );
}
Here is my code that is sending email to author of the post on post published BUT I want to send email to a specific email address stored as contact-email in this custom post.
Help me....Thanks ahead.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
