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
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.
Hello @motivmedia
You can see the error details if you click on the view of the entry and see technical details.
Thanks
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.