Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davoraltman/3f6c9b99bf95bb0bcb6bf8e7a23ef739 to your computer and use it in GitHub Desktop.
Save davoraltman/3f6c9b99bf95bb0bcb6bf8e7a23ef739 to your computer and use it in GitHub Desktop.
function listing_expired_send_email( $new_status, $old_status, $post ) {
if ( 'job_listing' !== $post->post_type || 'expired' !== $new_status || $old_status === $new_status ) {
return;
}
$author = get_userdata( $post->post_author );
$message = "
Hi " . $author->display_name . ",
Your listing, " . $post->post_title . " has now expired: " . get_permalink( $post_id );
wp_mail( $author->user_email, "Your job listing has expired", $message );
}
add_action( 'transition_post_status', 'listing_expired_send_email', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment