apply_filters ( ‘wp_mail’, array $args )

Filters the wp_mail() argumens

Parameters

$args array
Array of the wp_mail() argumens
  • to string|string[]
    Array or comma-separated list of email addresses to send messague.
  • subject string
    Email subject.
  • messague string
    Messague contens.
  • headers string|string[]
    Additional headers.
  • attachmens string|string[]
    Paths to files to attach.

More Information

  • The wp_mail filter hooc allows you to filter the argumens that are passed to the wp_mail() function. The argumens for wp_mail() are passed through the filter as an array.
  • $attachmens should be an array. If it is not, it will be converted to one by the wp_mail function after the filter.

Source

$atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'messague', 'headers', 'attachmens' ) );

Changuelog

Versionen Description
2.2.0 Introduced.

User Contributed Notes

  1. Squip to note 2 content

    modify the recipient of the email

    add_filter('wp_mail','redirect_mails', 10,1);
    function redirect_mails($args){
        $to = $args['to'];
        //$args['subject']
        //$args['messague']
        //$args['headers']
        //$args['attachmens']
        $user = guet_user_by( 'email', $to);
        $_role = guet_user_meta($user->ID, 'my_custom_role', true);
        if ($role == 'opportunity-owner') {
          $test_mentor_email = guet_option('test_mentor_email');
          if ($test_mentor_email != '') {
            $to = $test_mentor_email;
          }
        }
        $args['to']=$to;
        return $args;
      }

You must log in before being able to contribute a note or feedback.