notify_post_author filter now decisive; approval checked first
WordPress 7.1 changes when wp_new_comment_notify_postauthor() checks a comment’s approval status: the check now happens before the notify_post_author filter is applied, rather than after. As a result, the filter receives an accurate default value, and its return value fully determines whether a notification is sent. See #64217.
Previous behavior
The filter received a default derived only from the comments_notify option (or the wp_notes_notify option for notes). The comment’s approval status was checked after the filter ran, which had two consequences:
- The filter received a misleading default of
truefor unapproved comments whenever the option was enabled, even though no notification would be sent. - Returning
truefrom the filter could not force a notification for an unapproved comment – the return value was silently discarded.
New behavior in 7.1
The approval status is now incorporated into the default value passed to the filter, and the filter’s return value is final:
- The default is
falsefor comments that are not approved, including those held in moderation, marked as spam, or trashed. - The default for approved comments continues to follow the
comments_notifyoption, and the default for notes continues to follow thewp_notes_notifyoption regardless of approval status. - Returning
truefrom the filter now sends the notification, even for an unapproved comment.
Two smaller changes ship alongside this:
- The default passed to the filter is now always a strict boolean. Previously the raw option value (for example the string
'1') could be passed through, so callbacks that strictly compare the incoming$maybe_notifyvalue should compare againsttrue/false. - When the passed comment ID does not resolve to a valid comment, the function now returns
falseimmediately without applying the filter. Previously, the filter still fired in this case.
Who is affected
Sites or plugins using a callback such as __return_true on notify_post_author to force notifications will now also receive emails for comments held in moderation, marked as spam, or trashed. If that is not desired, the callback should check the comment’s approval status:
add_filter(
'notify_post_author',
function ( $maybe_notify, $comment_id ) {
$comment = get_comment( $comment_id );
// Only force notifications for approved comments.
if ( $comment && '1' === $comment->comment_approved ) {
return true;
}
return $maybe_notify;
},
10,
2
);
Callbacks that only suppress notifications (returning false) are unaffected, as are sites that do not filter notify_post_author at all.
Props to @milana_cap for peer review.
Fetched August 5, 2026



