Вход на сайт

Просмотр новости

Найдите то, что Вас интересует

The notify_post_author filter now has the final say on post author notifications

Дата публикации: 05-08-2026 12:22:02

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 […]

Основное содержимое страницы с новостью.

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 Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. 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

Схожие новости

#Наименование новостиТональностьИнформативностьДата публикации
1Accessibility Improvements in WordPress 7.109.5913-08-2026
2A unified public exposure flag for Abilities in WordPress 7.1010.0104-08-2026
3Iframed Editor Changes in WordPress 7.1010.9903-08-2026
4WordPress 7.1 Field Guide018.0605-08-2026
5WordPress 7.1 Release Candidate Phase011.7205-08-2026
6WordPress 7.1 Release Candidate 3013.0612-08-2026
7Responsive block styles and configurable viewports in WordPress 7.108.2705-08-2026
8WordPress 7.2 Call for Volunteers09.6412-08-2026
9What’s new in Gutenberg 23.7? (05 August)011.8506-08-2026
10Dev Chat Agenda – August 11, 202609.211-08-2026

Классификация: . Схожих патентов: 0. Схожих новостей: 10. Тональность: 0. Информативность: 8.41. Источник: make.wordpress.org.