Hi, I have this modified code from ‘TheDeadMedic, transfered by Viktor Dite’
<?php
/**
* Plugin Name: Email on New Post
* Plugin URI: http://wordpress.stackexchange.com/questions/19040/alert-email-when-any-post-or-page-is-changed
* Description: Send an email notification to the administrator when a new post of type "Entrada" or "circulars" is published.
* Author: TheDeadMedic, transfered by Viktor Dite
* Version: 1.0
* Copyright CC share alike
*
* @param string $new_status
* @param string $old_status
* @param object $post
*/
function wpse_19040_notify_admin_on_publish( $new_status, $old_status, $post ) {
if ( $new_status !== 'publish' || $old_status === 'publish' ) {
return;
}
// Check if the post type is 'post' (Entrada) or 'circulars'
if ( $post->post_type !== 'post' && $post->post_type !== 'circulars' ) {
return;
}
// Recipient
$emailto = 'EMAIL';
// Email subject and message for 'post' (Entrada)
if ( $post->post_type === 'post' ) {
$subject = '🌐 Nueva Entrada publicada: \'' . get_the_title( $post->ID ) . '\'';
$message = get_permalink( $post->ID );
}
// Email subject and message for 'circulars'
if ( $post->post_type === 'circulars' ) {
$subject = '📢 Nueva Circular publicada: \'' . get_the_title( $post->ID ) . '\'';
$message = get_field('circular_id', $post->ID); // Assuming 'circular_id' is the name of the custom field
}
wp_mail( $emailto, $subject, $message );
}
add_action( 'transition_post_status', 'wpse_19040_notify_admin_on_publish', 10, 3 );
?>
The ACF value get_field(‘circular_id’, $post->ID) is set, but the email is not send because it detects that there is not a value in circular_id. Any help?
Thanks.