Got it going,
For anyone else looking to do this, just use wordpress’s Post Status Transition {old_status}_to_{new_status} hook.
Here is what I did and it is working fine:
function on_publish_pending_post( $post ) {
$post_id = $post->ID;
$author_id=$post->post_author;
if ( ! tribe_is_event() ) return;
// If this is just a revision, don't send the email.
if ( wp_is_post_revision( $post_id ) ) return;
$subject = "Your event is live!";
$post_url = get_permalink( $post_id );
$post_title = get_the_title( $post_id );
$message .= "Your event has been approved and published publicly.";
$message .= $post_title . "<br>" . $post_url;
// Get the organizer's email address
$user_email = get_the_author_meta( 'user_email', $author_id );
// Send email to the organizer
wp_mail( $user_email, $subject, $message );
}
add_action( 'pending_to_publish', 'on_publish_pending_post', 10, 1 );
-
This reply was modified 10 years, 4 months ago by
Ameet.