发送邮件/自定义帖子类型更新

时间:2015-12-23 06:56:18

标签: php wordpress post custom-post-type

我已设法发送新帖子的电子邮件,但我试图在其他用户编辑任何帖子,页面和自定义帖子类型时发送电子邮件。仍然没有运气。

任何帮助将不胜感激。提前谢谢。

下面是代码,我用来发送电子邮件,当有人添加新帖子时。当有人更新时,我需要一些代码。

function wpse_19040_notify_admin_on_publish( $new_status, $old_status, $post ) {
if ( $new_status !== 'publish' || $old_status === 'publish' )
    return;
if ( ! $post_type = get_post_type_object( $post->post_type ) )
    return;

// Recipient, in this case the administrator email
 $emailto = get_option( 'admin_email' );

// Email subject, "New {post_type_label}"
$subject = 'New ' . $post_type->labels->singular_name. " added: ";

// Email body
$message = "There has been new post. Please check below:";
$message .= 'View it: ' . get_permalink( $post->ID );

wp_mail( $emailto, $subject, $message );
}

add_action( 'transition_post_status', 'wpse_19040_notify_admin_on_publish', 10, 3 );

0 个答案:

没有答案