WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been trying to get an email notification to fire when a new custom post type (in this case, "event"), is published. I've tried a few things and settled down to this simple example that, I imagine, should work just fine.

function admin_event_notification()

   $message = "Test";
   wp_mail( 'jonathan@sabramedia.com', 'New Event', $message );

add_action( 'new_event', 'admin_event_notification', 10, 3 );

Any ideas what I'm missing?

Once that works, the next step is accessing $post to get the title and permalinks, etc. I think I've got that covered, but any ideas are welcomed.

share|improve this question
Where do you hook your function? Is there action like - new_{custom_post_type}? – Mamaduka Dec 5 '11 at 19:03
up vote 1 down vote accepted

'new_event' is not a default wordpress hook. Hence the above will only work if you include do_action( 'new_event' ); in your custom post type's saving/publishing function.

Your usage of wp_mail is otherwise correct.

See the codex on do_action for reference.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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