如何为某些帖子禁用发送电子邮件通知新评论
对不起我的英语
如何为某些帖子禁用发送电子邮件通知新评论
对不起我的英语
您可以使用notify_moderator 和notify_post_author 用于控制是否应将评论通知发送给版主或评论作者的筛选器。
add_filter(\'notify_moderator\', \'prefix_filter_sent_comment_notification\', 10, 2);
add_filter(\'notify_post_author\', \'prefix_filter_sent_comment_notification\', 10, 2);
function prefix_filter_sent_comment_notification( bool $maybe_notify, int $comment_ID ) {
$comment = get_comment($comment_ID);
$comment_post = get_post($comment->comment_post_ID);
// determine, if notification should sent or not
// return true to send
// to not, return false
return some_logic_check( $comment_post ) ? false : $maybe_notify;
}
我有几个插件可以这样启动:namespace MyPlugin; // If this file is called directly, abort. if (! defined(\'WPINC\')) { die; } /** * Define Constants * */ define(__NAMESPACE__ . \'\\NS\', __NAMESPACE__ . \'\\\\\')