is there a suitable code for blocking all registered users' outgoing email but only the admin receives all emails. I need a send all emails to admin only situation.
-
1Are you asking for any specific plugin or what please elaborate your issue.– Pratik bhattFeb 9 at 11:50
-
are you asking how to do it, or for a product/plugin recommendation? Note that just asking for a copy paste solution is considered rude here, an answer is meant to explain how to do it so that people can learn, but dropping a block of code with no context is not considered a good answer. People may think you're asking them to work for free– Tom J Nowell ♦Feb 9 at 13:58
1 Answer
Mail sent from WP uses wp_mail()
function. There is a filter that you can use before the mail is sent to filter the arguments used in the wp_mail()
function, including the $to value.
See https://developer.wordpress.org/reference/hooks/wp_mail/
Look at the example code on that page to get an idea of how to block (or redirect) all mail sent by wp_mail()
. You could put your implementation of that in your Child Theme's functions file, or your own private plugin.
It is possible that a plugin or a theme might not use the wp_mail()
function, using instead mail()
or their own implementation of phpMailer (which wp_mail()
uses).