pre_wp_mail
Filter HookDescription
Filters whether to preempt sending an email. Returning a non-null value will short-circuit {@see wp_mail()}, returning that value instead. A boolean return value should be used to indicate whether the email was successfully sent. }Hook Information
File Location |
wp-includes/pluggable.php
View on GitHub
|
Hook Type | Filter |
Line Number | 214 |
Hook Parameters
Type | Name | Description |
---|---|---|
null|bool
|
$return
|
Short-circuit return value. |
array
|
$atts
|
{ Array of the `wp_mail()` arguments. |
Usage Examples
Basic Usage
<?php
// Hook into pre_wp_mail
add_filter('pre_wp_mail', 'my_custom_filter', 10, 2);
function my_custom_filter($return, $atts) {
// Your custom filtering logic here
return $return;
}
Source Code Context
wp-includes/pluggable.php:214
- How this hook is used in WordPress core
<?php
209 * @type string $message Message contents.
210 * @type string|string[] $headers Additional headers.
211 * @type string|string[] $attachments Paths to files to attach.
212 * }
213 */
214 $pre_wp_mail = apply_filters( 'pre_wp_mail', null, $atts );
215
216 if ( null !== $pre_wp_mail ) {
217 return $pre_wp_mail;
218 }
219
PHP Documentation
<?php
/**
* Filters whether to preempt sending an email.
*
* Returning a non-null value will short-circuit {@see wp_mail()}, returning
* that value instead. A boolean return value should be used to indicate whether
* the email was successfully sent.
*
* @since 5.7.0
*
* @param null|bool $return Short-circuit return value.
* @param array $atts {
* Array of the `wp_mail()` arguments.
*
* @type string|string[] $to Array or comma-separated list of email addresses to send message.
* @type string $subject Email subject.
* @type string $message Message contents.
* @type string|string[] $headers Additional headers.
* @type string|string[] $attachments Paths to files to attach.
* }
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/pluggable.php
Related Hooks
Related hooks will be displayed here in future updates.