Trying to overriding wp_mail function in wordpress plugin but another plugin doing the same overtakes it

211 Views Asked by At

I have a requirement to write a plugin to handle the default mails of Woocomerce. I am overriding the pluggable wp_mail function. This works fine but when another plugin overriding the same wp_mail is installed, it takes the control over.

Tried this: function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ){return true}

Why I am overriding wp_mail? My requirement is that when my plugin is installed, other plugins shouldnot be able to send emails. Earlier I tried only hooks for the Order events like

add_action('woocommerce_order_status_changed', array( $this, 'handle_order_status_change_events' ), 10, 3 );

But, with this the issue is that when any other plugin to handle mails is installed, duplicate mails are sent i.e one mail from my plugin and another from the other plugin. To handle this, I am overriding the wp_mail.

0

There are 0 best solutions below