You can do that with an action to transition_post_status and the wp_mail function to send an e-mail. You can learn more here: http://codex.wordpress.org/Post_Status_Transitions
Thanks for pointing me there; and while I love learning new things, my timeframe is tight. Unfortunately, I don’t know this type of stuff well, and need to get this site online asap.
Any chance you would be willing to provide some code to get this done, referencing only the attendee post type?
I would be willing to compensate you for your time, if necessary.
Thank so much!
Ok, I was more ambitious than I figured… I plugged this into the functions.php:
// function to be executed when custom post type tix_attendee is published
function new_registration_notify() {
$message = "Message...";
$headers = 'From: Who From <from@emailaddress.com>' . "\r\n";
wp_mail('to@emailaddress.com', "Subject...", $message, $headers);
}
add_action('publish_tix_attendee', 'new_registration_notify');
This actually seems to work! However, I’m receiving two copies of the email for some reason. Any idea why?
Not sure, but that action is fired in wp_transition_post_status
, and my guess is that it’s also fired for publish to publish transitions, so what you’d need is the other action called transition_post_status
. Off the top of my head:
function my_transition( $new, $old, $post ) {
if ( $new == $old || $new != 'publish' || $post->post_type != 'tix_attendee' )
return;
// do your stuff
}
add_action( 'transition_post_status', 'my_transition', 10, 3 );
When I switch to your code, I get the following in browser after submitting the form online:
Warning: Missing argument 2 for new_registration_notify() in /.../wp-content/themes/<theme>/functions.php on line 726
Note in case it’s in question: I did replace “\\do your stuff” with the wp_mail code.
Can you post the exact code you’re trying to use?
I replaced “\\do your stuff” with the wp_mail code that worked using the originally-posted function (only that one sent it twice).
Just paste the code that you’re using 🙂
Ok, I must have fat-fingered something the first time. Works perfectly!
Thank you very much for taking the time to answer this for me.