{"id":2645,"date":"2020-04-01T19:36:07","date_gmt":"2020-04-01T18:36:07","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=2645"},"modified":"2022-02-17T07:13:48","modified_gmt":"2022-02-17T07:13:48","slug":"filter-email","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/wordpress\/email-wordpress\/filter-email","title":{"rendered":"Filter Email"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Hook into wordpress send email function<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/********************************************\n\/\/********************************************\n\/\/********** FILTER OUTGOING EMAILS **********\n\/\/********************************************\n\/\/********************************************\n\/\/Any plugin or theme sending email is likely to be using wp_mail() to do it\nadd_filter( 'wp_mail', 'filter_wp_mail' );\nfunction filter_wp_mail( $args )\n{\n  \/\/$args Fields:\n  \/\/  $args&#91;'to']\n  \/\/  $args&#91;'subject']\n  \/\/  $args&#91;'message']\n  \/\/  $args&#91;'headers']\n  \/\/  $args&#91;'attachments']\n  \n  \/\/----- FILTER OUT EMAILS SENT BY DIVI CONTACT FORM -----\n\t\/\/if (strpos($args&#91;'subject'], 'New Message From') !== False)\n  if (strpos($args&#91;'to'], 'nosend@nosend.com') !== False)     \/\/&lt;We set the email address to this so we can trap them here\n\t{\n\t\t\t$args&#91;'to'] = \"\";      \/\/Remove the 'to' field to stop the email being able to be sent\n\t}\n  \n  return ($args);\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Hook into wordpress send email function<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[207],"tags":[],"class_list":["post-2645","post","type-post","status-publish","format-standard","hentry","category-email-wordpress"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=2645"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2645\/revisions"}],"predecessor-version":[{"id":3379,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2645\/revisions\/3379"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=2645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=2645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=2645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}