I setup a custom post type and everything works right. The user can submit for review and I see it's pending in the admin area. How can I have WordPress send me an Email Notification whenever a user submits a post?

add_action( 'init', 'artwork_feature');
function artwork_feature() {
register_post_type( 'artwork',
        'labels' => array(
            'name' => __( 'Artwork' ),
            'singular_name' => __( 'Artwork' )
    'public' => true,
    'exclude_from_search'       => false,
    'capability_type' => 'artwork',
    'supports' => array('custom-fields', 'comments'),
        'capabilities' => array(
            'publish_posts' => 'publish_artworks',
            'edit_posts' => 'edit_artworks',
            'edit_others_posts' => 'edit_others_artwork',
            'delete_posts' => 'delete_artworks',
            'delete_others_posts' => 'delete_others_artwork',
            'read_private_posts' => 'read_private_artwork',
            'edit_post' => 'edit_artwork',
            'delete_post' => 'delete_artwork',
            'read_post' => 'read_artwork',
    'map_meta_cap' => true,
    'has_archive' => true,
    'supports' => array('title', 'editor', 'thumbnail')

  • 2
    Is this something you've custom built? It is a plugin? By comments do you mean like Post Comments you would make on a blog? When you create a Post Type you should be able to set the option 'supports' => array('comments') View Codex – Howdy_McGee Mar 25 '14 at 20:52
  • I set it up in functions.php and I do have it set to supports => comments but I don't get any notifications. Yes I am talking about post comments which does work as expected. I added my code. – Brian Mar 25 '14 at 21:32
  • Is this not possible? – Brian Mar 27 '14 at 13:33
  • I've tested this with my Post Type and I get the Red (1) whenever somebody posts a comment. If you want email notifications, checkout Settings->Discussion – Howdy_McGee Mar 27 '14 at 13:50
  • 1
    I was able to find what I wanted with: Post Status Notifier Lite – Brian Mar 27 '14 at 17:30

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 ) )

    $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( 'admin@example.com', $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,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.