Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#10185 closed defect (bug) (invalid)

wp_mail filter does not return filtered strings

Reported by: anmari's profile anmari Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: wp_mail, filters, extract
Focuses: Cc:

Description

Firstly, if calling function wp_mail directly, one gets this message:

Warning: extract() [function.extract]: First argument should be an array in pluggable.php line 256

The code is:
extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );

apply filters returns a string with "array" ?, so this code does not appear to work.

Further down the filters are applied again individually for 'wp_mail_from' and 'wp_mail_from_name'
why not apply the wp_mail filters on the subject and body lines there rather?

If I do this, it seems to work.

Change History (4)

#1 @dd32
15 years ago

apply filters returns a string with "array" ?, so this code does not appear to work.

Are you sure your plugin is not incorrectly returning something on that filter? - It works as expected for me.

Further down the filters are applied again individually for 'wp_mail_from' and 'wp_mail_from_name' why not apply the wp_mail filters on the subject and body lines there rather?

As you can see in the code, Its mainly for legacy purposes that they're set separately.

Its possible to add them into the wp_mail filter.. but.. In the end, For back compat purposes, The other filters will remain in their current location, as well as the legacy code overriding the wp_mail filter..

#2 @anmari
15 years ago

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

Thanks for that confirmation - I thought I was going nuts going around in circles.

It must have been something I had in the code - after your positive confirmation, I cut the code down to absolute basics - it worked, then I built it up again and now it works, but I cannot see what I did that was different.

anyway - yes it does work and very conveniently so - can now access the "to" and filter the message accordingly - sweet!

#3 @Denis-de-Bernardy
15 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#4 @Denis-de-Bernardy
15 years ago

  • Milestone Unassigned deleted
  • Resolution set to invalid
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.