Send notification to the admin when new custom post is submitted
I have a cpt called "auto" and i make a frontend form to create new post with "pending" status. After the post submission i would receive an email with a notification of the new post.
function newpost_notify() {
$mailadmin = '[email protected]';
$subject = 'Subject';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'From: xxx [email protected]' . "\r\n";
$message = 'There\'s a new post.';
wp_mail( $mailadmin, $subject, $message, $headers );
}
add_action( 'publish_post', 'newpost_notify', 10, 2 );
This is my code..but i didn't receive any email.
I would know if there's a difference between a "new post" and a "publish post", because i read something about the post status transition.
Thank you
Topic wp-mail notifications customization custom-post-types Wordpress
Category Web