禁止WordPress自动升级后的邮件提示

背景

WordPress自3.7版本后内置了自动升级功能,对于安全度的提高非常有帮助。

但是本博客同一级域名下还有一个开发用的WordPress平台,安装的是开发版本,每天都会升级。WordPress在升级后会自动向管理员邮箱发送邮件通知,每天两封邮件,太过频繁了,自然要想办法禁用掉。
email-notification

方法

通知邮件会在下面三种情况下发送:

  1. 内核升级成功
  2. 升级出现错误
  3. 使用开发版本的情况下

所以我每天收到的两封邮件符合情况一和情况三。

将下面一段PHP代码放到一个已启用的插件中:
(一般添加额外功能的做法是把代码放在主题functions.php文件中,但是版本自动升级时,主题也会更新,覆盖主题文件,放在这儿的话,一旦functions.php文件被覆盖了,以后就又会恢复为自动发送的情况了)

原文

上述方法来自WordPress领头开发人之一的Andrew Nacin。其原文如下:

Emails are sent in three situations: a result email after a core auto update, a notification email when WordPress can’t update itself, and a debugging email when running a development version of WordPress (alpha/beta/RC).

The result email comes in three forms:

  • A successful update. Nice!
  • An update that couldn’t occur. As in, WordPress tried to update, but failed early, like an inconsistent permissions error it was able to catch.
  • A critical failure, when the update failed in the middle of copying files.

(Note, we’ve yet to see a single critical failure in the wild. Yeah, it’s that reliable.)

You can stop these emails from being sent by returning false via the auto_core_update_send_email filter:

Next, the core notification email is controlled by the send_core_update_notification_email filter. By default, administrators are notified when the update offer received from WordPress.org sets a particular flag — of course, only if the install is unable to update. It’ll only email you once per new version, unless the admin email changes. Returning true means the install will always email you when there is a new update, even if the API has not yet instructed the install to do so. Returning false prevents the email from ever being sent.

Finally, the debugging email is a complete log output of all auto updates performed — core, translations, plugins, and themes. It is as if you clicked update yourself and watched the text scroll by; it also includes additional error data if something went wrong. This email controlled by the automatic_updates_send_debug_email filter. Returning false will prevent this email from being sent when running a development install, while returning true will send this email to all versions, including when you’re on a stable release.

发布者

Leniy

Do not , for one repulse , give up the purpose that you resolved to effect . 本文著作版权归Leniy所有,并受法律保护。 转载、使用整体或任何部分的内容(包含但不限于各个页面的标题、评论框提示语)须经过Leniy的授权。 CopyRight © 2006-2017 Leniy.org all rights reserved.

《禁止WordPress自动升级后的邮件提示》有51个想法

    1. 想起来了,上个月的今天的那条垃圾评论就是你发的。难道是定时发送?

        1. 恩。自动更新这个的邮件提示,是3.7开始的。你3.8手动更新的,不会收到send_email和debug_email,过几个月升级3.9版本时,你就会看到了。我是因为用了3.9开发板,最多一天就会大更新,所以二到三封邮件每天都会发送。

发表评论

电子邮件地址不会被公开。 必填项已用*标注