Make WordPress Core

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#20353 closed enhancement (fixed)

Add filter for email recipients in wp_notify_moderator()

Reported by: lexhair's profile lexhair Owned by: nacin's profile nacin
Milestone: 3.7 Priority: normal
Severity: minor Version: 3.3.1
Component: Comments Keywords: has-patch needs-testing
Focuses: 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 12 years ago.
Applies 'comment_moderation_email_to' filters to $email_to array

Download all attachments as: .zip

Change History (9)

#2 @lexhair
13 years ago

#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.

#3 @juliobox
13 years ago

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?

@chipbennett
12 years ago

Applies 'comment_moderation_email_to' filters to $email_to array

#4 @chipbennett
12 years ago

  • 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

#5 @nacin
12 years ago

  • Milestone changed from Awaiting Review to 3.7

#6 @chipbennett
12 years ago

Thanks, Nacin! The related ticket #22922 is equally low-hanging fruit, and the two combined scratch a particular itch of mine.

#7 @nacin
12 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 25104:

Add filters to the recipients of emails sent by wp_notify_postauthor() and wp_notify_moderator().

The new filters are called comment_notification_recipients and comment_moderation_recipients.

Add the context of $comment_id to the comment_moderation_headers filter, to match the comment_notification_headers filter.

props chipbennett.
fixes #22922, #20353.

Note: See TracTickets for help on using tickets.