From your explanation, it seems that we need wp_mail()
function and post_updated
hook.
wp_mail()
reference: https://developer.wordpress.org/reference/functions/wp_mail/
post_updated
action hook: https://developer.wordpress.org/reference/hooks/post_updated/
<CPT_name>
– replace this with your custom post type key.
(Untested code – it should give you a good idea of what needs to be done)
add_action('post_updated', `send_custom_update`, 10, 3);
function send_custom_update($post_ID, $post_after, $post_before) {
if(get_post_type($post_ID) == '<CTP_name>') {
$to = '[email protected]';
$subject = get_the_title($post_ID) . ' has been updated!';
$body = 'The email body content';
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $to, $subject, $body, $headers );
}
}
If you look at the documentation of this action hook you will see that there are two versions of the post available – before and after edit. You might use them in the $body
– but that is up to you.
Let me know if this helps.