releases.sh

notify_post_author filter now decisive; approval checked first

1 feature3 enhancementsThis release1 featureNew capabilities3 enhancementsImprovements to existing featuresAI-tallied from the release notes
From the original release noteView original ↗

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:

  1. The filter received a misleading default of true for unapproved comments whenever the option was enabled, even though no notification would be sent.
  2. Returning true from 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 false for 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_notify option, and the default for notes continues to follow the wp_notes_notify option regardless of approval status.
  • Returning true from 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_notify value should compare against true/false.
  • When the passed comment ID does not resolve to a valid comment, the function now returns false immediately 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.

#7-1, #dev-notes, #dev-notes-7-1

Fetched August 5, 2026