Welcome Guest! Login? Checkout

WordPress in version 3.7 introduced a most welcome and a game changing feature – automatic updates. This slightly controversial-at-the-time feature allowed WordPress to automatically update minor or security releases without the need of user intervention. This was needed, as more WordPress installations out there are secure and safe, with fewer bugs. It is a good thing. A very, good thing.

However, if you manage a number of sites using something like ManageWP or WPRemote, you can get hundreds, even thousands of emails saying you need to update your site. Whilst useful for those with a small number of sites, it can be a bit much if you have a lot of users.

Furthermore, if a lot of your sites are hosted on the same server, or use the same email delivery method over a number of sites, this mass-sending of emails can cause problems. I trust WordPress to stagger the updates, but you never know.

As a result, you may wish to prevent emails being sent, but still go through the updates. Luckily, this is incredibly easy using a WordPress filter.

The auto_core_update_send_email filter

The filter you need is the auto_core_update_send_email filter. This filter accepts a number of arguments dependant on the email that is being sent.

To do so, create a new WordPress plugin. Simply include the following lines after the header:-

This will stop all email being sent after updates, but unfortunately it will stop all emails. You may want to allow some emails such as failures or critical errors through so you can act on them. Luckily this is quite possible.

The auto_core_update_send_email Parameters

There are a number of associated parameters with the auto_core_update_send_email. They are the following:-

  • $send – The result of whether to send an email. This is what you need to return.
  • $type – The type of the email to send. This is one off three values: “success”, “fail” or “critical”. “fail” means that the update failed. “Critical” means that the update failed and it has taken down the site.
  • $core_update – The update offer that is attempted. I’m not 100% sure what this is.
  • $result – The result of the update attempted, this can be an error message.

With this knowledge, we can build something better for email wise. To receive the emails only when there is an error, do the following code:-

I hope this turns out to be useful. As said earlier you shouldn’t have to disable your updates, but it is probably a good idea to limit the amount of emails to be sent, especially is nothing is wrong.

 
 
 

Comments

Polite Disclaimer: I am welcome, open and willing for corrections to be shared in the comments (with corrections being added to posts and credited), and the comments field should be used to promote discussion and make this post better. I do not know everything and if anybody finds a better way to do something, then by all means please share it below.

However, I'm unable to offer support to posts. The reason being is that WordPress has tens of thousands of plugins and millions of themes. As such, finding out exactly why code doesn't work with your setup is a long process. If you wish for me to look at your code, please use the priority support area.

Comments asking support will be left on the site, but there is no guarantee of answer.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">
*