Created
June 2, 2017 12:23
-
-
Save davoraltman/3f6c9b99bf95bb0bcb6bf8e7a23ef739 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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