Title: Add filter saving log
Last modified: December 20, 2024

---

# Add filter saving log

 *  Resolved [fgaillard](https://wordpress.org/support/users/fgaillard/)
 * (@fgaillard)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/add-filter-saving-log/)
 * 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
 *     ```wp-block-code
       $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
 *     ```wp-block-code
       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 1 year, 5 months ago by [fgaillard](https://wordpress.org/support/users/fgaillard/).

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

 *  Plugin Author [Michael](https://wordpress.org/support/users/donmhico/)
 * (@donmhico)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/add-filter-saving-log/#post-18213027)
 * Hello [@fgaillard](https://wordpress.org/support/users/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.
 *     ```wp-block-code
       <?phpadd_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 1 year, 5 months ago by [Michael](https://wordpress.org/support/users/donmhico/).
 *  Thread Starter [fgaillard](https://wordpress.org/support/users/fgaillard/)
 * (@fgaillard)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/add-filter-saving-log/#post-18213260)
 * 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.

 * ![](https://ps.w.org/wp-mail-logging/assets/icon-256x256.jpg?rev=2562296)
 * [WP Mail Logging](https://wordpress.org/plugins/wp-mail-logging/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-mail-logging/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-mail-logging/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-mail-logging/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-mail-logging/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-mail-logging/reviews/)

## Tags

 * [feature](https://wordpress.org/support/topic-tag/feature/)

 * 2 replies
 * 2 participants
 * Last reply from: [fgaillard](https://wordpress.org/support/users/fgaillard/)
 * Last activity: [1 year, 5 months ago](https://wordpress.org/support/topic/add-filter-saving-log/#post-18213260)
 * Status: resolved