Custom Post Type Alerts

WordPress has a save_post hook, which is an action triggered whenever a post or page is created or updated.

Add something like this below to your functions.php:

function my_project_updated_send_email( $post_id ) {

    // If this is just a revision, don't send the email.
    if ( wp_is_post_revision( $post_id ) )
        return;

    $post_title = get_the_title( $post_id );
    $post_url = get_permalink( $post_id );
    $subject="A post has been updated";

    $message = "A post has been updated on your website:\n\n";
    $message .= $post_title . ": " . $post_url;

    // Send email to admin.
    wp_mail( '[email protected]', $subject, $message );
}
add_action( 'save_post', 'my_project_updated_send_email' );

One thing to note is that your localhost by default will not send out an email to an external source – unless you have configured it. There is however a couple of plugins that will allow you to send via SMTP, that way you can easily test from localhost.

The example above is taken from the save_post codex page, however in addition to the above, you would want to add filters to only send it out for your custom post type and not every post, as well as maybe just for a fresh create rather than all updates (by specifying which post status you want alerts for) – up to you to decide.

All the best,
Kat