• Resolved fgaillard

    (@fgaillard)


    Hello,

    Is it possible to add a filter in the save_email_log method to define if the email must be logged (example: email to admin, password reset…)?
    By default, the filter would be set to true.

    Add this to line 531 in src/WPML_Plugin.php

    $save = apply_filters( 'wp_mail_logging_save_log_email', true, $mail_data );

    if (!$save) {
    return $mail_data;
    }

    In any files of a plugin or theme, you can do the following, for example

    add_filter('wp_mail_logging_save_log_email', function($save, $emailData) {
    if ($emailData['to'] == get_option('admin_email')) {
    return false;
    }
    return $save;
    }, 10, 2);

    Best regards,

    • This topic was modified 11 months, 4 weeks ago by fgaillard.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Michael

    (@donmhico)

    Hello @fgaillard,

    Thank you for creating this support thread. We have an existing filter, wp_mail_logging_before_log_email, which you can also use to achieve what you mentioned. You can use it like this.

    <?php
    add_filter( 'wp_mail_logging_before_log_email', 'wp_mail_logging_before_log' );

    /**
    * Filter which emails to log.
    *
    * @param array $mail_data Array containing the mail data to be logged.
    */
    function wp_mail_logging_before_log( $mail_data ) {
    if ( $mail_data['to'] === get_option('admin_email') ) {
    return false;
    }

    return $mail_data;
    }

    Hope this helps!

    Michael
    Lead Developer

    • This reply was modified 11 months, 3 weeks ago by Michael.
    Thread Starter fgaillard

    (@fgaillard)

    Hello,

    Sorry, I thought it would only allow me to modify the data and not not save it…


    Thanks for your reply!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Add filter saving log’ is closed to new replies.