Opened 14 months ago

Last modified 5 months ago

#20353 new enhancement

Add filter for email recipients in wp_notify_moderator()

Reported by: lexhair Owned by:
Priority: normal Milestone: Awaiting Review
Component: Comments Version: 3.3.1
Severity: minor Keywords: has-patch needs-testing
Cc:

Description

As administrator, I would like more control over email notifications when comments are marked for moderation without having to overwrite the pluggable function wp_notify_moderator.

The function wp_notify_moderator sends emails to post authors (when they have sufficient roles) and the admin by hard coding the $email_to array. I'd like to see the $email_to array sent to a filter with $comment before wp_mail() is called. That would allow me to write a theme function to manipulate the $email_to array to add or delete recipients.

My workaround was to write a site specific plugin that overwrote wp_notify_moderator() to manipulate the $email_to array.

Attachments (1)

pluggable.php.wp_notify_moderator.diff (676 bytes) - added by chipbennett 5 months ago.
Applies 'comment_moderation_email_to' filters to $email_to array

Download all attachments as: .zip

Change History (5)

Related: #8833

#8833 is a big task.

Many of the pluggable functions, including wp_notify_moderator() have filter hooks already available. This would be a simple line of code which I'd be happy to prepare a patch for that would apply a filter.

I could have made this work by hooking into wp_mail() but phpmailer makes the To: address property protected which was giving me fits to manipulate it.

I agree lexhair, this filter is easy to implement and in fact, i'm wondering why the foreach loops on a single item oO
It seems a filter is missing here!
How can i propose a patch?

Applies 'comment_moderation_email_to' filters to $email_to array

  • Component changed from General to Comments
  • Keywords has-patch needs-testing added

Patch passes $email_to array through apply_filters(), for the 'comment_moderation_email_to' filter.

Related: #22922

Note: See TracTickets for help on using tickets.