• Resolved motivmedia

    (@motivmedia)


    To deactivate mails sent to the admin when users change teir passwords the only working way to go seems to use the filter wp_password_change_notification_email and empty the To address. This leads to those mails apparently being tried to be sent and creating a log entry for a fail.

    This is definitely not a complaint, just wondering if you have any suggestions as I would prefer to keep “false positives” (in the sense of “positive although intended”) out of the log.

    • This topic was modified 1 year, 4 months ago by motivmedia.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Amimul Ihsan Mahdi

    (@amimulihsanmahdi)

    Hello there,

    We are quite unsure about the query, would you please provide a bit more context? It would be really helpful if you could provide some screenshots explaining the issue.

    Let me know the update.

    Thank you

    Thread Starter motivmedia

    (@motivmedia)

    Hello Amimul.
    As I wrote, the (seemingly only working) way to disable sending password change notifications in WordPress based on conditions instead of wholesale is to filter the array used to send it and remove the recipient (to) there. THis is the code:

    add_filter('wp_password_change_notification_email', function($wp_password_change_notification_email, $user) {
    	if($user->roles == array('subscriber')) {
    		$wp_password_change_notification_email['to'] = '';
    	}
        return $wp_password_change_notification_email;
    }, 10, 2);

    My tests gave me those in the log file view:

    View post on imgur.com

    I’m fully aware that trying to send an email without an adressee will fail. I am not saying the log entry is wrong. But as you can see from my code, it is my intention that those mails aren’t sent, so I’m basically getting false positives in the sense that there is no problem. This is something I’d prefer to prevent. And I’m not sure what to do.

    Again, I don’t see a flaw in your plugin. Just the chance that you might know a better way to achieve what I want – suppressing mails under certain conditions – without creating log entries.

    Plugin Author Shahjahan Jewel

    (@techjewel)

    Hello @motivmedia
    You can see the error details if you click on the view of the entry and see technical details.

    Thanks

    Thread Starter motivmedia

    (@motivmedia)

    Yes. I know. And it is because the “To” is empty. Intentionally, as the only way to reliably prevent a mail getting sent. As seen in my code and as described.

    My question is if you can suggest a way to achieve what I need to – preventing mails to get sent as most precisely explained by the very code (unedited) I commented – without creating log entries. My reasoning being that I don’t need to be warned of anything that I very much intentionally did.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_password_change_notification_email and fail entries’ is closed to new replies.